JavaScript functions

JavaScript functions, arrow functions, and closures

Learn JavaScript functions with focused lessons on function declarations, expressions, arrow functions, parameters, return values, rest and spread, closures, callbacks, call, apply, bind, and currying.

Function lessons and concepts

  1. Function basics

    Define reusable behavior with function declarations, parameters, local variables, return values, and clear names.

    Outcome: Turn repeated logic into reusable units that make programs easier to read.

    • JavaScript functions
    • function declaration
    • return value
    Study Functions
  2. Function expressions

    Store functions in variables, pass behavior around, and understand when expressions are useful.

    Outcome: Use functions as values in events, arrays, promises, and configuration objects.

    • function expression
    • JavaScript callback
    • first-class functions
    Study Function expressions
  3. Arrow functions

    Write compact functions with arrow syntax and understand how arrow functions differ from regular functions.

    Outcome: Choose arrow functions for short callbacks and regular functions where their behavior matters.

    • arrow functions
    • JavaScript arrow function
    • fat arrow
    Study Arrow functions, the basics
  4. Rest parameters and spread syntax

    Collect many arguments into arrays and expand arrays into function calls or copied values.

    Outcome: Write flexible functions that accept variable input without brittle argument handling.

    • rest parameters
    • spread syntax
    • JavaScript arguments
    Study Rest parameters and spread syntax
  5. Closures and scope

    Understand lexical scope and why functions keep access to variables from the environment where they were created.

    Outcome: Use closures for callbacks, factories, encapsulation, and async behavior.

    • JavaScript closures
    • lexical scope
    • variable scope
    Study Variable scope, closure
  6. Function object and NFE

    Inspect function object properties, named function expressions, and metadata attached to callable values.

    Outcome: Understand functions as objects with names, lengths, and callable behavior.

    • function object
    • named function expression
    • function properties
    Study Function object, NFE
  7. New Function syntax

    Learn the dynamic Function constructor, its scope behavior, and why it should be used sparingly.

    Outcome: Recognize dynamic function generation without confusing it with ordinary declarations.

    • new Function
    • Function constructor
    • dynamic JavaScript
    Study The "new Function" syntax
  8. Callbacks

    Pass functions as continuation logic and understand how callbacks model asynchronous or event-driven work.

    Outcome: Read callback-based APIs before moving into promises and async/await.

    • JavaScript callbacks
    • callback function
    • asynchronous callbacks
    Study Introduction: callbacks
  9. Decorators, call, and apply

    Wrap functions, forward arguments, and control invocation with call and apply.

    Outcome: Build wrappers that preserve behavior while adding logging, caching, or validation.

    • call apply
    • function decorators
    • forwarding arguments
    Study Decorators and forwarding, call/apply
  10. Function binding

    Use bind to lock this, create partial functions, and avoid lost context when methods are passed around.

    Outcome: Keep method context predictable in callbacks, handlers, and object APIs.

    • JavaScript bind
    • this binding
    • partial application
    Study Function binding
  11. Arrow functions revisited

    Revisit arrow functions after learning this, closures, and methods so their tradeoffs are clear.

    Outcome: Avoid using arrow functions where a dynamic this value is required.

    • arrow function this
    • lexical this
    • advanced arrow functions
    Study Arrow functions revisited
  12. Currying and partials

    Transform function calls into reusable steps and pre-fill arguments for specialized behavior.

    Outcome: Recognize functional patterns used in utility libraries and reusable application code.

    • JavaScript currying
    • partial functions
    • functional JavaScript
    Study Currying