JavaScript · JS Tutorial · Lesson 10
JS Data Types
String, Number, BigInt, Boolean, undefined, null, Symbol and Object.
JavaScript has 8 data types: String, Number, BigInt, Boolean, Undefined, Null, Symbol and Object. Variables are dynamic — the same variable can hold different types.
Example
<p id="demo"></p>
<script>
let length = 16; // Number
let lastName = "Johnson"; // String
let isOk = true; // Boolean
let big = 1234567890123456789012345n; // BigInt
let car; // undefined
let person = { firstName: "John" }; // Object
let cars = ["Saab", "Volvo"]; // Array (an object)
document.getElementById("demo").innerHTML =
typeof length + ", " + typeof lastName + ", " + typeof isOk + ", " +
typeof big + ", " + typeof car + ", " + typeof person + ", " + typeof cars;
</script>
Tip:
typeof null returns "object" — a long-standing bug in JavaScript.Keep reading “JS Data Types”
Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.