Introducing Primitive Data Types

In the last few lectures, we discuss Values & Variables and Convention and Rules for naming Variables. Values can have different types in every programming language, depending on the kind of data we want them to hold. And we already saw strings and numbers but there are more data types. So, let's now take a look at all the data types we have in the javascript.

First of all, in javascript, every value is either an Object or Primitive value. We will learn all about Objects later but for now, let's focus on Primitive data types.

let me = {
    firstName: 'Akhil',
    secondName: 'Naidu',
    age: 24   
An example of an Object; We haven't introduced it yet; this is for comparison.
let firstName = 'Akhil';
let secondName = 'Naidu';
let age = 32
An example of Primitive; A value is only Primitive if it is not an Object

Primitive Data Types

There are seven primitive data types, number, string, boolean, undefined, null, symbol, and BigInt. So let's look at them one by one.


The numbers are always so-called floating-point numbers, which means that they always have decimals, even if we don't see them or don't define them.

let age = 23;

// You can use this as a test to check it
console.log(100/3) // 33.333333333333336
Here the age is implicitly 23.0000000, but it is simply a number data type.

In many other programming languages, you will find different data types for Integers and Decimals, but not in javascript. In javascript, both integers and decimals come under a single number datatype.


Strings are nothing but a sequence of characters, and so they are used for text, as we discussed earlier. Also, don't forget to put them in double or single quotes; Otherwise, javascript will get confused with variable names.

let firstName = 'Akhil';
Without the quotes for value, javascript will confuse it with variable names.

My convention was to use a single quote, but you can also prefer double-quotes.


The boolean data type is essentially a logical type that can only take one of the logical values true or false. In other words, a boolean is either true or false. We use boolean values to take decisions with code, as we will see later.

let isProgammer = false;

let javascriptIsFun = true;
console.log(javascriptIsFun); // true
If you finished this course, in the end, we could change it as true
These three data types, number, string, and boolean are the most frequently used and essential data types.


Undefined is the value taken by the variable that is not yet defined. A variable that's not yet determined is simply a variable that we declared without assigning a value.

let hero; // hero was a defined variable but it has empty value
console.log(hero); // undefined

hero = 'Naruto'; // Assgining a value to variable
console.log(hero); // Naruto

// myFavHero is not a variable yet, it was not defined.
console.log(myFavHero); // error: Uncaught ReferenceError: myFavHero is not defined
There is a difference between Undefined and not defined

So, we can say that Undefined means an empty value to an existing variable.


Null is also pretty similar to Undefined because it also means empty value, but it is used in different circumstances. For now, don't worry about the details, I just want you to know that null also exists.


Symbols were introduced in ES2015(ES6), and this data type was not valuable for us; it is used to define a unique value that cannot be changed. And we will talk about this briefly by the end of this course.


Starting with ES2020, there is also BigInt for integers that are too large to be represented by the number type. So, basically, it is another type of number , and we will talk about this one in another section.

These are the Seven primitive datatypes in javascript, and comparative to other programming languages using types in javascript is a lot easier. It is a lot easier because javascript is based on Dynamic Typing, and we will look into it in the next section.

You've successfully subscribed to Leewardslope
Great! Next, complete checkout to get full access to all premium content.
Error! Could not sign up. invalid link.
Welcome back! You've successfully signed in.
Error! Could not sign in. Please try again.
Success! Your account is fully activated, you now have access to all content.
Error! Stripe checkout failed.
Success! Your billing info is updated.
Error! Billing info update failed.