Data Types define what kind of value a variable stores.
- Primitive data types ##
String - let name = "Priya"; // text
Number - let age = 20; //integer or decimal
Boolean - let pass = true; //true or false
Undefined - let a; //value not assigned
Null - let b = null; //empty value
BigInt -let n = 12345678901234567890n; //very large integer
Symbol - let id = Symbol("id") //unique identifier
- Non-Primitive Data Type ##
- Object - stores data as key-value pairs.
let person = {
name: "Priya",
age: 25
};
console.log(person.name); //Priya
- Array - stores multiple values in a single variable.
let colors = ["red" , "blue" , "green"];
console.log(colors[1]); //blue
Top comments (0)