*args vs **kwargs
*args captures extra positional arguments and **kwargs captures extra keyword arguments.
- args becomes tuple
- kwargs becomes dict
- Useful for flexible APIs
*args vs **kwargs
Tagged with functions
*args captures extra positional arguments and **kwargs captures extra keyword arguments.
*args vs **kwargs
Default argument values are evaluated once at function definition time, which makes mutable defaults a common bug source.
Default arguments and mutable default values
Functions are first-class values in Python, so you can pass them around, return them, and build closures or higher-order helpers.
First-class functions, higher-order functions, lambda functions, and closures
Python lets you control how callers pass arguments so APIs can be both flexible and explicit.
Positional, keyword, keyword-only, and positional-only arguments
Python functions can return any object, often pack multiple results into a tuple, and may document intent through annotations and docstrings.
Return values, multiple return values, function annotations, and docstrings
A decorator wraps another callable to add behavior without changing the original function body.
What is a decorator?
JavaScript functions are first-class values, which is why callbacks, higher-order utilities, and different function forms all matter.
Function declarations, function expressions, arrow functions, default parameters, rest parameters, callbacks, higher-order functions, first-class functions, IIFE, and pure functions
These patterns solve different problems: recursion for self-referential logic, memoization for caching, currying for partial application, and debounce or throttle for rate control.
Recursion, memoization, currying, debounce, and throttle in JavaScript
`this` depends on how a function is called, and `call`, `apply`, and `bind` let you control that context explicitly.
The this keyword in global scope, methods, regular functions, arrow functions, and call/apply/bind