JavaScript data types (primitives)
the building blocks of web apps
We can categorize basic forms of data, known as primitives, as follows:
Number
a value we can calculate with another
an integer like
3
,-1
or0
a floating point number like
-273.15
String
a value with one or more alphanumeric characters
plain text like
String
orHello world!
plain text that has non-calculatable numbers like
Price: $200
Boolean
a value that is either true or false
true
false
null
a placeholder value
(null
implies that some value should exist)
undefined
a value signifying the lack of a value
(undefined
implies that no value exists)
Object
a value with a structure that consists of a set of properties, each with a name and value
{ username : "Jon", age: 100, alive : true }
Contrary to what the browser console might say, null
is not an Object
but its own primitive type (this is a long-standing bug in JavaScript!)
Last updated