← JavaScript tutorial

JavaScript

Data Types

JavaScript's core types: string (text, in quotes), number (JavaScript uses one type for both whole numbers and decimals, no separate "integer" type), boolean (true or false), array (an ordered list), and object (key/value pairs).

Example: checking a value's type

const text = "hello";
const count = 42;
const isReady = true;

document.getElementById("output").textContent =
  typeof text + ", " + typeof count + ", " + typeof isReady;

typeof tells you a value's type at runtime, genuinely useful when a value's type isn't obvious just from reading the code, like data that just arrived from an API response. Try changing count to a string like "42" in the editor and notice how typeof now reports "string", a subtle but real difference that trips up a lot of beginners comparing "42" to 42 later on.

Try it yourself
Ready to go further?

These free tutorials are a preview, our Frontend Development cohort covers it in depth, with a real project and a cohort alongside you. Active

Enroll in Frontend Development
Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account