Sikau

JavaScript · Day 11 · about 25 min

Types

Knowing what kind of value you have.

What kind of thing is this?

You've met numbers, strings and booleans. Today you'll learn how to ask JavaScript what kind of value something is — and how to turn one kind into another. This is the last lesson of Unit 2!

typeof

Every value has a type. The typeof keyword tells you which:

console.log(typeof 42);
console.log(typeof "42");
console.log(typeof true);

The rest of this lesson

  • Empty boxes: undefined and nullexplain
  • Turning text into numbersexplain
  • Why types matter in real appsexplain
  • What type is it?predict
  • Match the typematch
  • Quick checkquiz
  • Fix the form mathswrite code
  • Detective workwrite code
  • Unit 2 project: Trip calculatorchallenge
  • Unit 2 complete!recap

Continue this lesson free — run real code in your browser

Continue with Google

See all 68 lessons of JavaScript