In JavaScript, data types describe the kind of value a variable can hold. JavaScript is a dynamically typed language, meaning you don't need to declare the type explicitly.
The typeof operator is used to check the data type of a variable.
typeof variableName;
let name = "Ahmed";
let age = 25;
let isStudent = true;
let city;
let score = null;
let user = { name: "Ahmed", age: 25 };
let colors = ["red", "green", "blue"];
console.log(typeof name); // string
console.log(typeof age); // number
console.log(typeof isStudent); // boolean
console.log(typeof city); // undefined
console.log(typeof score); // object (JavaScript quirk)
console.log(typeof user); // object
console.log(typeof colors); // object
Click the button to see the data types in action: