Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
JAVASCRIPT FOUNDATIONS / CHAPTER 01 / Learn / LESSON 03
Third class. Not every value is the same. The number 1500, the text "1500", and the boolean true are different types.
The typeof operator reports the type: typeof 1500 → "number", typeof "hi" → "string", typeof true → "boolean". typeof itself returns a string — the word number/string/boolean.
Why care? Because "50" + 10 concatenates text, while Number("50") + 10 adds. Type decides behavior.
Mini example:
console.log(typeof 42);Common mistake: expecting typeof to return Number with a capital letter — it is always lowercase: "number".
typeof returns the type name as a string. Print it with console.log.
JS CONSOLE IDLE
›