Mobile development

Stage 1 · Lesson 6 of 9

null, undefined and optional values

JavaScript and TypeScript

has two empty values. undefined is what you get for a missing property or a variable with nothing in it yet. null is usually set on purpose.

With strict mode, a string cannot hold either unless its type says string | undefined, so the compiler makes you handle the gap. Use to read safely, as in user?.profile?.photo, and nullish coalescing, ??, for a default.

Know why ?? is safer than ||. count || 10 turns a real 0 into 10, while count ?? 10 keeps it.

Common trapthe non-null assertion user!.name, which tells the compiler to trust you and crashes at runtime when the data is missing.

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

Resources for this stage

Start with· follow one of these

  • CoursePaid
    Grokking JavaScript Fundamentals

    Design Gurus · Beginner · $50

    Beginner JavaScript with an exercise after most lessons

  • GuideFree
    JavaScript.info

    Ilya Kantor

    Free and thorough: Part 1 is the language, skip the browser chapters in Part 2

Practise

  • Dart, TypeScript, Kotlin and Swift tracks with small exercises and free mentor feedback

Keep handy

Also worth your time

Mark this stage as not done?