JavaScript Data Types
JavaScript variables can hold different data types: numbers, strings, objects and more.
Data Types
- String: Represents textual data.
let color = "Yellow"; - Number: Represents numeric data.
let length = 16; - BigInt: Represents large integers.
- Boolean: Represents true or false.
let x = true; - Undefined: A variable without a value.
- Null: Represents the intentional absence of any object value.
- Symbol: A unique and immutable primitive value.
- Object: A collection of properties.
const person = {firstName:"John", lastName:"Doe"};
The typeof Operator
You can use the typeof operator to find the type of a JavaScript variable.
javascript
typeof "John" // Returns "string"
typeof 3.14 // Returns "number"
typeof true // Returns "boolean"
typeof {name:'John'} // Returns "object"Test Yourself with an Exercise
What is the data type of `true`?