Interview Q&A / JavaScript

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What are the primitive data types in JavaScript?

SHORT ANSWER

JavaScript has seven primitive types: string, number, bigint, boolean, undefined, null and symbol. Everything else, including arrays and functions, is an object.

Explain it simply

Think of primitives as single coins in your pocket: a coin is just a value, you cannot open it up and change what is inside. Objects are more like a wallet: one container that can hold many things and can be changed.

The seven primitives are:

  • string: text, like "IRCTC"
  • number: integers and decimals share one type, like 42 or 3.14
  • bigint: whole numbers bigger than Number.MAX_SAFE_INTEGER, written with an n, like 10n
  • boolean: true or false
  • undefined: a variable that has been declared but given no value
  • null: a value you set on purpose to mean "nothing here"
  • symbol: a unique identifier, mostly used as object keys

Primitives are immutable. When you "change" a string, JavaScript actually builds a new string.

Example

js
console.log(typeof "IRCTC");     // Output: string
console.log(typeof 42);          // Output: number
console.log(typeof 10n);         // Output: bigint
console.log(typeof true);        // Output: boolean
console.log(typeof undefined);   // Output: undefined
console.log(typeof Symbol("id")); // Output: symbol
console.log(typeof null);        // Output: object
console.log(typeof [1, 2]);      // Output: object

What to say in the interview

"There are seven primitives: string, number, bigint, boolean, undefined, null and symbol. They are immutable and compared by value. Everything else is an object, including arrays and functions, and objects are compared by reference. One quirk: typeof null returns 'object', which is a historical bug kept for backward compatibility."

Common mistakes

  • Saying there are separate integer and float types. JavaScript has one number type (64-bit floating point), plus bigint.
  • Forgetting symbol and bigint, which were added in ES6 and ES2020.

#javascript#types

Related questions

Practise more JavaScript questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open JavaScript quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.