JavascriptMedium
Language View:
What are Primitive Data Types in JavaScript?
Answer (English)
There are 7 primitive data types:
String
Number
Boolean
Null
Undefined
Symbol
BigInt
Examples1
1Example 1
Primitive Data Types in JavaScript
There are 7 primitive data types in JavaScript:
String â Represents text.
let name = "John"; console.log(name); // "John"Number â Represents both integers and floating-point numbers.
let age = 25; let price = 99.99; console.log(age); // 25 console.log(price); // 99.99Boolean â Represents
trueorfalse.let isLoggedIn = true; let hasPermission = false; console.log(isLoggedIn); // true console.log(hasPermission); // falseNull â Represents an intentional empty value.
let data = null; console.log(data); // nullUndefined â A variable that has been declared but not assigned a value.
let city; console.log(city); // undefinedSymbol â Represents a unique and immutable value.
let id = Symbol("id"); console.log(id); // Symbol(id)BigInt â Represents very large integers beyond the safe
Numberlimit.let bigNumber = 1234567890123456789012345678901234567890n; console.log(bigNumber);
More from
Discussion0
Please sign in to leave a comment.
