Data Types — Complete Guide
Data Types — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of JavaScript Tutorial on Toolliyo Academy.
On this page
JavaScript Tutorial · Lesson 5 of 100
Data Types
Basics → Objects & data → Async & DOM → Advanced → Tools → Projects
Beginner · 1 — Learn by example · ~6 min · JS Tutorial — Basics
What is this?
Every value in JavaScript has a type: string (text), number, boolean (true/false), undefined, null, object, and more. typeof tells you what type a value is.
Why should you care?
Adding "5" + "3" gives "53" (string concat). Adding 5 + 3 gives 8 (math). Knowing types prevents silent bugs.
See it live — copy this example
Paste into an HTML file or the browser console (F12). Use Run below when the live editor is available.
console.log(typeof "hello");
console.log(typeof 42);
console.log(typeof true);
console.log(typeof undefined);
let person = { name: "Amit", age: 22 };
console.log(typeof person);
Run Example »
Edit the code below and click Run to see the result in Toolliyo’s live editor.
What happened?
- Strings use quotes.
- Numbers have no quotes.
- typeof returns a string naming the type.
- Objects hold grouped data — person is an object.
Practice next
- Run each typeof line in the console.
- Try typeof null and note the quirk.
- Create let x; without assigning and check typeof x.
- Add typeof for a function: typeof function(){}.
- Create a bigint with 100n and log typeof 100n.
Remember
typeof shows the type Use quotes for strings, not for numbers Objects group related data
ScriptVerse API validation
A form handler checks typeof age === "number" before saving a profile — strings from inputs would break math otherwise.
Outcome: Type checks at boundaries catch bad data before it reaches the database.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!