What are the data types in JavaScript?
JavaScript has 7 primitive types and the object type.
| Type | Example |
|---|---|
| String | "Hello" |
| Number | 42, 3.14 |
| Boolean | true |
| Undefined | A variable without a value |
| Null | An empty value on purpose |
| BigInt | 10n |
| Symbol | A unique identifier |
| Object | Arrays, functions, dates and plain objects |
console.log(typeof "hi", typeof 5, typeof true, typeof undefined, typeof {});
Output:
Tutorials Class - Output Window
string number boolean undefined object
Learn more about the similar topics:
| Tutorials |
|---|
| JavaScript Variables |
| JavaScript Scope |
| JavaScript Data Types |
| JavaScript Type Conversion |
| JavaScript Operators |
| JavaScript Numbers and Math |
| Exercises & Assignments |
|---|
| Write a JavaScript program to add two numbers |
| Write a JavaScript program to swap two variables |