Data Types in JavaScript

In programming, data types in Java script specify the type of data that a variable can hold. They define the operations that can be performed on the data and the way the data is stored in memory. Data types are fundamental to understanding how to manipulate and store data effectively within a programming language.

Types of Data Types in JavaScript

 

   JavaScript has two main categories of data types:

 

  • Primitive Data Types.
  • Non-Primitive (Complex) Data Types.

 

Primitive Data Types

These are the most basic data types and are immutable (i.e., their values cannot be changed once

created). JavaScript has seven primitive data types:

Number: Represents both integer and floating-point numbers.

Example: let RollNo = 30; // integer

let temperature = 98.6; // floating-point number

String: Represents a sequence of characters.

Example:   let name = "Alice";

let greeting = 'Hello, world!';

Boolean: Represents a logical entity and can have two values: true or false.

Example:    let isUser = true;

let isManager = false;

Null: Represents the intentional absence of any object value.

Example:  let userData = null;

Undefined: Represents a variable that has been declared but has not yet been assigned a

value.

Example: let user; // if you check the value of user. You get output ->  Undefined

Symbol: Represents a unique and immutable value, often used as object property identifiers.

Example:   const sym1 = Symbol('description');




BigInt: Represents whole numbers larger than 2^53 – 1

(which is the largest number   JavaScript can safely represent with the Number type).

Example: let bigIntValue = 1234567890123456789012345678901234567890n;

 

 

Non-Primitive (Complex) Data Types.

Object: Used to store collections of data and more complex entities.

Example: let person = {

name: "Alice",

age: 30,

isStudent: false

};

Array: A special type of object used for storing ordered collections of values.

Example:  let name = ["ashwani", "abhi", "shivaam"];

 

Also Read:-

Bootstrap : Most popular CSS library in the World

JavaScript code embedded within a HTML file:

Also visit :-

https://inimisttech.com/

Leave a Reply