Simple data types:
Complex data type:
The typeof operator
Following strings can be returned:
- “undefined” – if the value is undefined,
- “boolean” – if the value is false or true,
- “string” – if the value is a string,
- “number” – if the value is a number,
- “object” – if the value is an object (including arrays) or null,
- “function” – if the value is a function.
var a = "one", b = 2; console.log(typeof a); // string console.log(typeof b); // number
Data types meaning
The undefined value indicates that expected value is not defined and is only one value of the undefined type.
The null value is considered to be an empty object reference and is only one value of the null type.
Booleans, strings and numbers are other primitive values. Boolean represents logical truth and falsehood, string is sequence of Unicode characters, number simply represents all numbers.
Object is a collection of properties, where each property has a name and a value. Ordinary objects are unordered collections of named values.
An array is special kind of object, which contains an ordered collection of numbered values.