JavaScript has seven data types and two data structure types. Those data types are called primitive values and data structure types are called non-primitive values.

Primitive values:

In JavaScript, a primitive is a data that is not an object and has no methods. Primitive values are checked by typeof() operator. Primitive values are-

  1. Undefined
  2. Null
  3. Booleans
  4. Numbers
  5. Strings
  6. BigInts
  7. Symbols

Undefined: A variable that has not been assigned a value has the value undefined. It’s more like unintentional missing value.

let y ;

console.log(typeof y) // undefined

Null: It’s more like intentionally missing values. It’s a special primitive type. If the object is not inherited, then null is shown.

let x = null

console.log(typeof x) //object — — → Its an object but the value is null

Boolean: Boolean used for logical operator. It has two values which are true or false.

function isBoolean( n ) {

return !!n === n;

}

console.log(type of isBoolean(4)) // Boolean

Numbers: The Number type is a double-precision 64-bit binary format value (numbers between -(253 − 1) and 253 − 1). Numbers are used for math calculation.

const x = 7;

console.log(typeof x) // number

String: String used to represent textual data. It is a set of elements. Each element occupies a position in the string and the first element is at index 0 and next is 1 and so on.

const x = “Minhaz”

console.log(typeof x) // string

Symbol: A “symbol” represents a unique identifier. It used to hide implementation details. Even if we make many symbols with the same description, they are different values. The description is just a label that doesn’t affect anything. In some programming language symbol is called “atoms”.

Const x1 = Symbol(“Minhaz”);

Const x2 = Symbol(“Minhaz”);

console.log(x1 === x2) //false

BigIngt: BigInt is used to stored and work with big numbers. It is larger than 253–1. It is a build-in object.

const withoutBig = 88934598598493;

const withBig = BigInt(“898981899835”);

console.log(typeof withoutBig); // number

console.log(typeof withBig); // bigint

Non-primitive values:

Objects such as function are called non-primitive. That means they are mutable. Non-primitive values are two types. Which are objects and function.

Objects: In JavaScript object is a set of properties and each property is defined as a key-value pair. Example of object -

Const student = {

Id: 823,

Name: “Minhzul Abedin”,

Subject: “CSE”

}

// In this student object there are three properties.

An array is also one kind of object in javaScript.

Function: Function is one of the most fundamental things in javaScript. JavaScript has a function keyword for declaring it. The function is used to refer to code. Example:

Function name(){

console.log(“Minhazul Abedin”)

}

name(); // Minhazul Abedin

Full stack Web developer