In JavaScript, primitive data types are the most basic, immutable forms of data that are not objects and have no methods or properties. They are stored directly by value in the memory stack, meaning each variable holds its own distinct copy of the data.
JavaScript has seven primitive data types:
- String: Represents textual data enclosed in quotes.
let Name = "Ragul";
- Number: Represents both integers and floating-point numbers.
let Age = 21;
- Boolean: Represents logical values, either
trueorfalse.
let isDeveloper = True;
- Null: Represents the intentional absence of any value.
let currentUser = null;
- Undefined: Represents a variable that has been declared but not assigned a value.
let winningLotteryNumber;
console.log(winningLotteryNumber); // Outputs: undefined
- Symbol: Represents a unique identifier, often used for object property keys.
let uniqueKey = Symbol("user_id");
- BigInt: Represents integers with arbitrary precision, allowing for numbers larger than the standard Number limit.
let viewCount = 9007199254740998n;
Top comments (0)