- 
                Notifications
    
You must be signed in to change notification settings  - Fork 0
 
apply
        Subhajit Sahu edited this page Jul 29, 2022 
        ·
        2 revisions
      
    Invoke a function with specified this-object, and arguments provided as an array.
function apply(x, ths, args)
// x:    a function
// ths:  this object to invoke with
// args: arguments arrayconst xfunction = require('extra-function');
var array = [1];
xfunction.apply(Array.prototype.push, array, [2, 3, 4]);  // push(2, 3, 4)
array;
// → [1, 2, 3, 4]
var array = [1, 2, 3, 4];
xfunction.apply(Array.prototype.splice, array, [1, 2]);  // splice(1, 2)
array;
// → [1, 4]