Creating a Value
A value can be created in 2 different ways:
Using the constructor form results in an object wrapper around the primitive value.
This gives access to the helpful properties & methods such as
toUpperCase for a string.
Each native constructor has its own prototype object.
These contain properties & methods unique to their object subtype.
When the constructor form is used, the returned object's prototype property is set constructor's prototype object.
This is how you get access to the properties & methods.
Date(..) constructor accepts optional arguments to specify the date/time to use.
Format used below is ISO 8601 format -
YYYY-MM-DDTHH:mm:ss.sssZ (international standard).
An error object captures the current execution stack context into the returned object.
Stored in property
This includes the function call-stack and the line-number where the error object was created.
If you require a variable in a regex, it must be created using the constructor form.
The representations for
0.2 are not exact.
When added, the result isn't
0.3, it closer to
Number.EPSILON is predefined with this tolerance value that can be used as a workaround:
NaN- Not a Number
A primitive like
“abc” is not an object.
However, you can call methods on it like
This is possible through a technique called boxing.
When the interpreter sees a property or method call on a primitive, it calls the constructor form & passes in the primitive value, creating an object.
This object has properties & methods linked to it via the prototype chain.
typeof operator inspects the type of the given value & returns one of seven string values (except for
To test for a
null value using its type:
Note, variables don't have types. Only values do.
typeof against a variable, it's asking what's the type of the value in this variable?
Objects are tagged with an internal
A classification (not related to class-oriented coding) corresponding to the built-in native constructor.
It can only be accessed through