Skip to content
Subhajit Sahu edited this page Aug 7, 2022 · 1 revision

Invoke a function with specified this-object, and arguments provided individually.

Similar: call, apply.


function call(x, ths, ...args)
// x:    a function
// ths:  this object to invoke with
// args: arguments

const xasyncfn = require('extra-async-function');


var array = [1];
xasyncfn.call(Array.prototype.push, array, 2, 3, 4);  // push(2, 3, 4)
array;
// → [1, 2, 3, 4]

var array = [1, 2, 3, 4];
xasyncfn.call(Array.prototype.splice, array, 1, 2);  // splice(1, 2)
array;
// → [1, 4]


References

Clone this wiki locally