Primitive Data Types
Any value that you use is of a certain type. In JavaScript, there are the following primitive data types:
Number—this includes floating point numbers as well as integers, for example 1, 100, 3.14.
String—any number of characters, for example "a", "one", "one 2 three".
Boolean—can be either
true
orfalse
.Undefined—when you try to access a variable that doesn't exist, you get the special value
undefined
. The same will happen when you have declared a variable, but not given it a value yet. JavaScript will initialize it behind the scenes, with the valueundefined
.Null—this is another special data type that can have only one value, the
null
value. It means no value, an empty value, nothing. The difference withundefined
is that if a variable has a valuenull
, it is still defined, it only happens that its value is nothing. You'll see some examples shortly.
Any value that doesn't belong to one of the five primitive types listed above is an object. Even null
is considered an...