JS Built-ins
Functioncallbeginner

Function.prototype.call() β€” pass arguments

πŸ“– Usage Example
function add(a, b) { return a + b }
add.call(null, 3, 4)  // β†’ 7

Pass arguments individually to call() after the this argument.

fn.call(thisArg, arg1, arg2, ...)

After the this argument, call() accepts individual arguments to pass to the function.

Challenge: Use call() with null as this and pass 2, 3 to an add function.

πŸ’‘ Hints (2)
  • β€’ Use `null` as the first argument when `this` is not needed.
  • β€’ Arguments come after the `thisArg`.