Data Types


Data types:

The data type is the building block of any programming language. It’s an essential piece of any program.

Data types make the foundation of JavaScript programs. JavaScript has two types of data types such as

  1. Primitive data types and
  2. Object data type

Primitive data types:

The following are primitive data types…


1. Number: any number or number with a decimal. As for example →

console.log(1.2);

2. BigInt type: It is also a numeric data type but the difference with number is that BigInt is used when we have to store, and operate large integers beyond the safe integer limit.

> const x = 2n ** 53n;
9007199254740992n

3. String:  Any grouping of keyboard characters (letters, spaces, number, or symbol) surrounded by single(‘’) quote or double quotes(“”). As for example → 

console.log("Hello");

4. Booleans: true or false value with no quotation. 

console.log(true);

5. Null: null value. The absence of value.

6. Undefined: same as null but it has a different use than null.

7. Symbol: symbols are unique identifiers and used for complex coding.

8. Collection of related data.


Object Data type:

In JavaScript, the Object data type is used to create a complex data structure containing properties. Properties are composed of key-value pairs. If we want to access the properties of the object, then we have to do that with the key of the Object.

const object = { name: "John Doe", age: 23, isAdmin: true }

The syntax of the object consists of object literals (curly braces ). Here name, age, and isAdmin are the property of the object where the name, age, and isAdmin are also known as key of the properties of the object.

"John Doe", 23, and true is the value of the properties of the object.


Next: JavaScript Operators

Post a Comment

Previous Post Next Post