JavaScript: Primitive Value
Primitive Value
A primitive value is a value whose type is a primitive type.
[see Value Types]
The following values are βPrimitive Valuesβ.
undefined
null
true
,false
- any number (includes
NaN
andInfinity
) - any string [see String Overview]
- any symbol [see Symbol Tutorial]
Primitive Value Object Wrapper
Most primitive type have corresponding object of object type.
The object is used as primitive value wrapper.
This allows you to call methods on them, such as "abc".length
.
You can create number, string, boolean, objects yourself. (but is not useful.) For example:
new String(arg)
[see String Constructor]
new Number(arg)
[see Number Constructor]
new Boolean(arg)
[see Boolean Constructor]
Convert Primitive Value to Object
Use
Object(val)
[see Object Constructor]