Primitive type

๐Ÿท๏ธ Javascript

Javascript has 6 primitives:

All primitive types, except null, can be tested with typeof. If using typeof null, it returns object

All primitive type, except null and undefined have their corresponding object wrapper types

When accessing a property on a primitive type, Javascript wraps the value into the corresponding wrapper object and accesses the property on the object instead

Acessing a property on null and undefined throw TypeError exception

undefined means the absence of a value (return with no value, accessing a nonexistent object property, declaring a variable without initialization, methodโ€™s return when no element is found)

null means the absence of an object (used in prototype chain)

Number

Number.MIN_VALUE: 2^-1074

Number.MAX_VALUE: 2^1024

Number.MIN_SAFE_INTEGER: -(2^53 - 1)

Number.MAX_SAFE_INTEGER: 2^53 - 1

Number.MAX_VALUE < number -> +Infinity

number < Number.MIN_VALUE -> +0

-number < -Number.MAX_VALUE -> -Infinity

-Number.MIN_VALUE < -number -> -0

BigInt

created by appending n to the end of an integer or calling BigInt()

String

Immutable

Symbol

unique and immutable, can be used as the key of an object


https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#primitive_values