Types

JavaScript has 8 types:

Object

The object data type can contain both built-in objects, and user defined objects

Built-in Objects can be:

  • arrays
  • dates
  • maps
  • sets
  • intarrays
  • floatarrays
  • promises
  • objects
  • and more

Arrays

const car_makers = ["Hyndai", "Honda", "Toyota", "Kia"];

Dates

// Create a new Date object with the given date
//
// January 1, 1970 is Linux "epoch"
const epoch = new Date("1970-01-01");

String

const hello = "Hello";

Number

JavaScript’s Number covers both integers (whole numbers, i.e. 1, 5, 10, 1000), and floats (decimals, i.e. 3.14, 9.81)

// an "integer" (This is a number)
const answer = 42;
// a "float" (This is also a number)
const gravity = 9.81;

The Number type holds upto 15 digits of precision

Bigint

A Bigint holds big integers (no decimals)

const big = 1234567890123456789012345n;
const big2 = Bigint(1234567890123456789012345);

Bool

// Booleans are either true or false
const always = true;

Null & Undefined


2025-02-14