Programming foundations

Stage 1 · Lesson 4 of 10

Functions, scope and arrow functions

Your first language

package logic under a name. You will see three forms: function declarations, function expressions and , such as const add = (a, b) => a + b. They behave much the same until the keyword this gets involved, which comes later.

A function without return gives back undefined. Logging with console.log is not the same as returning. let and const have : a variable declared inside an if or a loop does not exist outside it.

Inner functions can read variables from the functions around them. Also learn default parameters (a value used when none is passed) and (...args, which gather extra arguments into an array). Small functions that take inputs and return values are what closures, and tests all build on.

A question to check yourself, an AI practice session and 2 cheat sheet entries come when you add the roadmap to your account. Add it

Resources for this stage

Start with· follow one of these

  • CoursePaid
    Grokking JavaScript Fundamentals

    Design Gurus · Beginner · $50

    The language itself, closures and async included, with runnable exercises per lesson

  • GuideFree
    JavaScript.info

    Ilya Kantor

    Free: Part 1 is the most complete modern JavaScript tutorial, with tasks per chapter

Practise

  • Small exercises in your language track, with free feedback from a human mentor

  • Foundations path: the JavaScript basics lessons and the exercises repo with tests

Keep handy

  • The JavaScript reference: look up every array and string method here

Mark this stage as not done?