June
26th,
2017
Primitive types:
- string
- number
- boolean
- null
- undefined
Complex types:
- function
- object
In JavaScript arrays are objects.
undefined
In JavaScript, a variable without a value, has the value undefined. The typeof is also undefined.
null
In JavaScript null is “nothing”. It is supposed to be something that doesn’t exist.
Unfortunately, in JavaScript, the data type of null is an object.
You can consider it a bug in JavaScript that typeof null is an object. It should be null.
Difference Between Undefined and Null
JavaScript evaluates expressions from left to right. Different sequences can produce different results:
JavaScript has dynamic types. This means that the same variable can be used to hold different data types: