Frontend development

Stage 2 · Lesson 1 of 10

Values, types and equality

JavaScript and the browser

has a few primitive : string, number, boolean, null, undefined, bigint and symbol. Everything else is an object, including arrays and functions. Declare variables with const by default, and with let when you must reassign.

Avoid var, which ignores . JavaScript converts between types silently, which is called coercion, and it causes most beginner surprises. "5" + 1 is "51", while "5" - 1 is 4.

The values 0, "", null, undefined and NaN all count as false in a condition, so they are called falsy. Always compare with ===, which checks type and value, not ==, which converts first. Use ?? to supply a default only for null or undefined, because || also replaces 0 and an empty string. Everything later in the stage assumes you can predict these results.

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

  • CoursePaid
    Grokking JavaScript Fundamentals

    Design Gurus · Beginner · $50

    Guided beginner course on the language core, with quizzes after every chapter

  • GuideFree
    JavaScript.info

    Ilya Kantor

    Free and thorough: Part 1 for the language, Part 2 for the DOM and events, Part 3 for fetch

Practise

  • Thirty small browser projects with no framework to hide behind

  • Free JavaScript curriculum exercises for daily reps on the language core

Keep handy

  • JavaScript and Web API reference, including fetch, the DOM and events

Also worth your time

Mark this stage as not done?