JS Data Types

JS Data Types

JS Data Types

 

In JavaScript, there are several data types that can be used to store and manipulate values. The most commonly used data types in JavaScript are:

  1. Numbers: Used to store numeric values, including integers and decimals.

Example:

				
					let x = 5; // Integer

let y = 3.14; // Decimal
				
			
  1. Strings: Used to store textual data.

Example:

				
					let firstName ="John";

let lastName = 'Doe';
				
			
  1. Booleans: Used to store true/false values.

Example:

				
					let isAlive = true;

let isHungry = false;
				
			
  1. Undefined: Used to represent a variable that has not been assigned a value.

Example:

				
					let x; // Undefined
				
			
  1. Null: Used to represent a variable that has been explicitly assigned a value of null.

Example:

				
					let x = null;
				
			

6.    Objects: Used to store collections of data as key-value pairs.

Example:

				
					let person = { firstName:
"John", lastName: "Doe", age: 30 };
				
			
  1. Arrays: Used to store collections of data as a list.

Example:

				
					let fruits = ["apple",
"banana", "orange"];
				
			
  1. Symbols: Used to create unique identifiers for objects.

Example:

				
					console.log( 'Code is Poetry' );const mySymbol = Symbol();
				
			

These data types can be used in a variety of ways to manipulate and store data in JavaScript, and it’s important to understand how they work and how to use them effectively in your code.

Join To Get Our Newsletter
Spread the love