Javascript–Variables and Data Types

Javascript is a Dynamically Typed language meaning the Interpreter assigns variables a type at runtime based on the type of data in the variable at that time. Javascript is one of the dynamically typed or untyped languages.

How do we declare the variable in Javascript. Very simple!! No need to mention the type of variable.



let studentName = “Raghu”;

There are 8 basic data types in Javascript.

Seven primitive data types:

  1. number – numbers of any kind (integers or floating point)
  2. Bigint – for integer numbers of arbitrary length
  3. string – for strings
  4. boolean – for true/false
  5. null – for unknown values
  6. undefined – for unassigned values
  7. symbol – for unique identifiers

Non-primitive data type:

  1. Object – for more complex data structures

In the below example, let us see how the variables for the above data types are declared and used:



//Below are the primitive data types

let studentName = "Raghu";
let studentId = 215;
let passPercentage = 89.85;
let isPass = true; 
let bigInt = 1234567890123456789012345678901234567890n;
let address = null;
let marks;
let symbolId = Symbol("id");

console.log("Data type of -- studentName is: "+typeof(studentName));
console.log("Data type of -- studentId is: "+typeof(studentId));
console.log("Data type of -- passPercentage is: "+typeof(passPercentage));
console.log("Data type of -- isPass is: "+typeof(isPass));
console.log("Data type of -- bigInt is: "+typeof(bigInt));
console.log("Data type of -- address is: "+typeof(address));
console.log("Data type of -- marks is: "+typeof(marks));
console.log("Data type of -- symbolId is: "+typeof(symbolId));


    <script type=”text/javascript” src=”alldatatypes.js”>

Console Output


In the first screenshot which is of the Javascript file. We can see for every data type, variable declaration is same. I have just used the “let” keyword. Simple right??

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.