A primitive is an immutable data value or data type that is not an object and has no properties or methods. In JavaScript, there are 6 primitive data types: string, number, boolean, null, undefined, and symbol. Except for null and undefined, JavaScript automatically boxes (wraps) all primitive values with their native object equivalents in order to access methods using the prototype chain. String for the string primitive:

See the Pen thecodelog.com - JS Primitives and Natives 1 by Deano (@deangilewicz) on CodePen.

Number for the number primitive.

See the Pen thecodelog.com - JS Primitives and Natives 2 by Deano (@deangilewicz) on CodePen.

Boolean for the Boolean primitive.

See the Pen thecodelog.com - JS Primitives and Natives 3 by Deano (@deangilewicz) on CodePen.

Symbol for the Symbol primitive.

See the Pen thecodelog.com - JS Primitives and Natives 4 by Deano (@deangilewicz) on CodePen.

To get the underlying primitive value out of a boxed (wrapped) value, the valueOf() method can be used:

See the Pen thecodelog.com - JS Primitives and Natives 5 by Deano (@deangilewicz) on CodePen.

There are many built-in objects (natives) in JavaScript. Some of them include the following…

See the Pen thecodelog.com - JS Primitives and Natives 6 by Deano (@deangilewicz) on CodePen.

Most of these native objects can be created (instantiated) in a couple of ways. One is using the new keyword followed by the native object name, the other is without the new keyword and using the literal form. Regardless of the approach used, behind the scenes JavaScript acts like you used the new keyword. For example, when creating an array you can use the new keyword followed by Array(..) or the new keyword can be omitted and the literal form used – square [] brackets.

See the Pen thecodelog.com - JS Primitives and Natives 7 by Deano (@deangilewicz) on CodePen.

Similarly, when using the Object(), Function(), and RegExp() natives, we can omit the new keyword and use the literal form:

See the Pen thecodelog.com - JS Primitives and Natives 8 by Deano (@deangilewicz) on CodePen.

However, the Date() and Error() natives do not have a literal form:

See the Pen thecodelog.com - JS Primitives and Natives 9 by Deano (@deangilewicz) on CodePen.

The Symbol() native does not support the new keyword syntax. Every symbol value returned from Symbol() is unique. A symbol value may be used as an identifier for object properties.

See the Pen thecodelog.com - JS Primitives and Natives 10 by Deano (@deangilewicz) on CodePen.