What are the Three Primitive JavaScript Data Types?

What are the Three Primitive JavaScript Data Types?


In JavaScript, a primitive (primitive value, primitive data type) is data that is not an object and has no methods or properties. The term data type refers to the different types of values that a program can operate with. Variables in JavaScript may hold a variety of data types, including numbers, strings, booleans, and more.

JavaScript, unlike many other programming languages, does not specify multiple types of numbers such as integers, short, long, floating-point, and so on.

In this tutorial, you will learn about the three primitive data types available in JavaScript: numbers, strings of text (known as “strings”), and boolean truth values (known as “booleans”).


Number represents integer and floating numbers (decimals and exponentials). JavaScript numbers can be written with or without decimals.

let num = 34; // A number without decimals

Floating-Point Numbers

JavaScript numbers can also have decimals.

let price = 29.99;


JavaScript strings are used for storing and manipulating text.
A string can be any text and must be surrounded by quotes. You can use single or double

let name = ‘Tom’;
let text = “My name is Tom Adams”;

You can use quotes inside a string, as long as they don’t match the quotes surrounding
the string.

let text = “My name is ‘Tom’ “;


In JavaScript Boolean, you can have one of two values, either true or false.
These are useful when you need a data type that can only have one of two values, such as Yes/No, On/Off, True/False.

let isActive = true;
let isAway = false;

Boolean values also come as a result of comparisons:

let isGreater = 6 > 2;

alert(isGreater); // true (the comparison result is “yes”)

Further reading

Want to learn more about JS Data Types? Then check out this article on JavaScript Data Types – W3Schools

If you liked this article, then please share. You can also find me on Twitter for more updates.

Pin It on Pinterest