Data Types

Every value in JavaScript has a type. The typeof operator tells you what type a value is.

The basic types

Try changing the values below and see how the type changes:

Try it yourself
Console output
  • String — text, written in quotes: "hello"
  • Number — any number, whole or decimal: 42, 3.14
  • Booleantrue or false

Arrays and objects

An array holds an ordered list of values. An object holds named properties:

Try it yourself
Console output
Note: array items are accessed by position, starting at 0 — so colors[0] is the first item, not the second.