Skip to content
techsnow

JavaScript Basics

Data Types

Every value in JavaScript has a type.

TypeExampleDescription
String"hello", 'hi'Text
Number42, 3.14, -7Integers and decimals
Booleantrue, falseYes or no
undefinedundefinedA variable with no value yet
nullnullIntentionally empty
BigInt9007199254740993nVery large whole numbers
Object{ name: "Ali" }Collections of values; arrays are objects too

Checking a type

console.log(typeof "hi");       // "string"
console.log(typeof 42);         // "number"
console.log(typeof true);       // "boolean"
console.log(typeof undefined);  // "undefined"
console.log(typeof { a: 1 });   // "object"
console.log(Array.isArray([])); // true