Data Types

JavaScript data types

JavaScript has 6 data types:

  • Numbers
  • String (text)
  • Boolean
  • Undefined
  • Null
  • Objects


Numbers are any number without quotes, including numbers with decimals.

For example: -10, 258, 3.14.


Strings are characters wrapped in single or double quotes.


let str = "Hello World";


undefined represents a lack of defined value.

Variables declared but not initialized to a value will have the value undefined.

let x;
console.log(typeof x); // undefined


null represents the intentional absence of a value. So it’s empty, and there’s nothing in it.

const x = null;


Boolean has 2 values: true or false.

In Javascript, 0, empty strings, undefined, null, and NaN (Not-A-Number) are all considered false values.

const isGood = true;


An object is the collection of related data.

let dog = {
  name: "Puppy",
  age: 2,
  color: "gray",

name, age, and color are the properties of the dog object. We access the values of these properties using the dot or bracket notation.

// Using dot
console.log(; // Puppy

// Using bracket
console.log(dog["age"]); // 2