Your guide to the JavaScript programming language

Primitive Data Types in JavaScript


To work with data in JavaScript, it's important to understand data types. Data types are a fundamental concept in any programming language and have a direct impact on how your code behaves.

So far you've learnt how to assign values to variables. We can classify these values into 7 primitive data types:

  1. String
  2. Number
  3. BigInt
  4. Boolean
  5. null
  6. undefined
  7. Symbol

Each data type has unique properties and methods available that enable you to perform various operations and manipulations on data.


Strings are used to represent text in JavaScript and can be enclosed in single quotes, double quotes, or backticks.

const name = "John";
const greeting = 'Hello World';
const fruit = `mango`;


Numbers are used to represent numerical values in JavaScript, and they can be integers, decimals, or scientific notation.

let age = 24
let weight = 63.63


BigInts are a new data type in JavaScript that allow you to represent integers with arbitrary precision. They were introduced in ES2020 to address the limitation of the Number data type, which can only represent integers up to 2^53 - 1 accurately.

let bigNum = 12345678901234567890
let bigInt = BigInt(12345678901234567890);
console.log(bigNum); // 12345678901234567000
console.log(bigInt); // 12345678901234567168n


Booleans represent logical values of true or false and are commonly used in conditional statements and loops.

let isWeekend = false
let isWeekday = true


All variables by default have the value undefined until they're defined or assigned a value.

console.log(y) // undefined
let x
var y
console.log(x) // undefined
x = 3
console.log(x) // 3


null is a special value in JavaScript that represents the intentional absence of a value unlike undefined. It can only be assigned explicitly by you and is not assigned by JavaScript.

let x
console.log(x) // undefined
x = null
console.log(x) // null


Symbols are a new data type introduced in ES6 that are used to create unique identifiers that cannot be modified or replicated.

const mySymbol = Symbol('unique');
const unique = 'unique'
console.log(mySymbol == unique) // false

You'll learn more about all these data types in detail and the different operations that you can perform on them in future posts. So stay tuned!