JS: Value Types
Variables don't have type.
Any value in JavaScript is one of the following type.
type name | sample value | explanation |
---|---|---|
undefined † | undefined |
undefined is the only value of this type. |
null † | null |
null is the only value of this type. |
boolean † | true |
true, false are the only possible values. |
string † | "xyz" |
〔see String Overview〕 |
number † | 34 |
Includes special value NaN (Not A Number) and Infinity |
symbol † |
Symbol()
|
Always-unique value primarily for use as property keys. 〔see Symbol Tutorial〕 |
object | {"x":3} |
The “object” type is a collection of (key and value) pairs. Many object has special purpsoes, e.g. Array, function, date, regex, etc. 〔see Object Type〕 |
† A value of these types are called Primitive Value.