JSFiddle - React, Tailwind, and code Playground
by brbcoding
JavaScript
function foo() {
return;
};
var fns1 = [];
var fns2 = [];
var fns3 = [];
for(var i = 0; i < 99999; i++) {
fns1.push(foo);
fns2.push(foo);
fns3.push(foo);
}
console.time('shift()()');
while(fns1.length) fns1.shift()();
console.timeEnd('shift()()');
console.time('Function.prototype.call');
fns2.forEach(Function.prototype.call, Function.prototype.call);
console.timeEnd('Function.prototype.call');
console.time('Straightforward');
fns3.forEach(function (cb) {
cb();
});
console.timeEnd('Straightforward');