< 1 minute read

call() or method calls a function with a given this value and arguments.

Let’s have a look at an example how to use call() method:

function Product(name, price) { = name;
    this.price = price;

function Food(name, price) {, name, price);
    this.category = 'food';

console.log(new Food('cheese', 5).name);

Output: cheese

apply() or Function.prototype.apply() method is similar to call(), the only difference is that the arguments are sent as an array.

call() and apply() are builtin methods on every JavaScript function.

Other builtin methods are:

  • Function.prototype.apply()
  • Function.prototype.bind()
  • Function.prototype.isGenerator()
  • Function.prototype.toSource()
  • Function.prototype.toString()