JS Built-ins
Functioncallbeginner

Function.prototype.call() β€” typeof this

πŸ“– Usage Example
const arr = [1, 2, 3]
Math.max.call(null, ...arr)  // β†’ 3

Use call() to invoke built-in methods with a custom this or argument list.

fn.call() β€” this is an object

When you pass an object as thisArg, this inside the function will be that object. typeof that object is 'object'.

Challenge: Verify that typeof getThis.call({x: 1}) returns 'object'.

πŸ’‘ Hints (1)
  • β€’ `this` in a regular function is the `thisArg` passed to `call()`.