JavaScript

This page gently explains JavaScript data types and how the kind of value affects the operations you can perform.

Goal: recognize strings, numbers, booleans, and other common types so you can choose an appropriate operation for each value.

Data types

Values in a program have different kinds. A value's kind is called its data type. For example, "Taro" is a string and 100 is a number.

The eight JavaScript types

String
Text surrounded by single quotes, double quotes, or backticks.
Number
Integers and floating-point numbers within JavaScript's Number range.
BigInt
Integers of arbitrary size, written with an n suffix such as 123n.
Boolean
One of two values: true or false.
null
An intentional indication that a value is empty or absent.
undefined
A value that has not been assigned or is not available.
Symbol
A unique and immutable identifier.
Object
A collection of properties and values. Arrays and many built-in structures are objects.

Primitive values and objects

The first seven types are primitive types. Objects are non-primitive values that can group properties or elements. This distinction affects how values are copied, compared, and changed.

JavaScript

const name = "Taro";       // string
const age = 20;            // number
const registered = true;   // boolean
const missing = null;      // intentionally empty

console.log(typeof name);  // "string"
console.log(typeof age);   // "number"

When you are unsure of a value's type, typeof is a useful first check. Remember that typeof null returns "object" for historical reasons; treat null explicitly when that distinction matters.

Related topics