Skip to content

JavaScript Tutorial Variables and Values

JavaScript Primitive Values

Lesson 15 of 258 2 min read By Deepak Paswan Updated Oct 4, 2026

Every value in JavaScript has a type. There are two groups: primitive values (simple, single values) and objects (everything else, such as arrays and functions).

The seven primitives

TypeExampleUsed for
string"hello"Text
number42, 3.14Most numbers
bigint9007199254740993nVery large whole numbers
booleantrue, falseYes or no
undefinedundefined“No value has been set”
nullnull“Intentionally empty”
symbolSymbol("id")Unique identifiers
script.js
JS
const name = "Maya";        // string
const age = 28;             // number
const isStudent = false;    // boolean
let nothingYet;             // undefined
const empty = null;         // null

console.log(name, age, isStudent, nothingYet, empty);

Primitives are immutable

You cannot change a primitive value. You can only replace it with another.

script.js
JS
let word = "cat";
word[0] = "b";       // silently ignored
console.log(word);   // → cat

word = "bat";        // replacing the whole value works
console.log(word);   // → bat

String methods never change the original. They return a new string.

Primitives vs objects

Primitives are compared and copied by value. Objects are handled by reference, which means two variables can point at the same object.

script.js
JS
let a = 5;
let b = a;
b = 10;
console.log(a, b); // → 5 10

const first = { n: 1 };
const second = first;   // both names point at the same object
second.n = 99;
console.log(first.n);   // → 99

Changing second changed first, because they are the same object. You will see this again in the Objects chapter.

The next lessons look at each type in turn: undefined and null, booleans, numbers, strings, BigInt and Symbol.