Mobile development

Stage 1 · Lesson 2 of 9

Functions, closures and this

JavaScript and TypeScript

In , functions are values, and code passes them everywhere: onPress handlers, for array methods and . Learn function declarations and arrow functions, plus default and rest parameters. Then learn : a function keeps access to the variables from where it was created.

Closures explain the most common React bug, the stale closure. That is when a handler or effect still sees a value from an earlier render. Learn how this works too.

A regular function gets this from how it is called, while an arrow function takes it from the code around it. Modern React code uses functions and hooks rather than classes, so this matters less than it once did.

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?