Primitive Data Types

Any value that you use is of a certain type. In JavaScript, there are the following primitive data types:

  1. Number—this includes floating point numbers as well as integers, for example 1, 100, 3.14.
  2. String—any number of characters, for example "a", "one", "one 2 three".
  3. Boolean—can be either true or false.
  4. 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 value undefined.
  5. 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 with undefined is that ...

Get Object-Oriented JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.