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
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
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
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
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
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
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
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
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
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
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
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
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