Aisha Wahab O.
3 min readJan 2, 2024

Do you know your data types in Javascript?
Data types are important in programming because it allows operation on variables. Without data, it is impossible to solve certain operations.

Data types are broadly categorised into two : Primitive and Object. The Primitive data are further divided into : number, string, Boolean, null, undefined and symbol.

1. Number - You can perform any operation with the num. For instance,

let num = 78;
let height = 3.45;

Range of numbers to work with are the powers of ten. If it's bigger than that it might lead to inconsistencies, however such numbers can be replaced by BigInt. BigInt is used when you have a bigger integer and you don't want to lose any precision. There is a specific integer value that Javascript allows, but with the help of BigInt, we can go further. It is however not allowed to mix BigInt and other types of data in your operations. For instance,
let z = BigInt("123456789012345678901234567890");

As for decimal numbers, they are referred to as floating point.

Anytime you want to know the type of data in your output, there is a special representation called type of. It is an operator that allows us determine a Javascript variable.
Floating points can also be represented by exponential. e.g.

let num 1 = 1.5e12
console.log(num1);

Is also same as 1.5 * 10^12 (exponential).

For large numbers, use underscores not comma to separate them. E.g. 100_000_255 not 100,000,255. The latter is not allowed as commas have special meaning in Javascript.

You can also work with infinity e.g.

let num 1 = 5/10 console.log(num 1); 

Infinity can either be positive or negative. Operations beyond the maximum value also lead to infinity.

2. Strings - A string is a sequence of characters. For example ,

let user = "Aisha"
console.log(user);

the "Aisha" above is a string.
Strings can be written in single or double quotes, as much as it doesn’t match the quotes surrounding the string. If you want to use quotes inside a string, follow the example below.

let user = "Aisha Wahab \"Oluwaseyi\""
console.log(user);

Output = Aisha Wahab “Oluwaseyi”

You can also create strings with other special characters, like \n (newline) or \t (tab).

For instance,

let user = "Aisha \nWahab"
console.log(user);

let user = "A\tisha \nWahab"
console.log(user);

It is also possible to combine two expression in string. For instance,

let firstName = "Aisha"
let lastName = "Wahab"

let user = firstName + " " + lastName
console.log(user);

3. Boolean- they are mainly used for true or false expressions. For instance.

let bool = 5 > 6
console.log(bool);

Output = False.

However,

let bool = 5 < 6
console.log(bool);

Output = True.

4. Null and Undefined - Null is used to represent the absence of values or no values in Javascript. For example,

let number = null;

However, undefined indicates that a variable isn't set yet or doesn't have a value yet. Example. Let Aisha;
This value is undefined.

Aisha Wahab O.
Aisha Wahab O.

Written by Aisha Wahab O.

I currently write on JavaScript. .

No responses yet