call vs apply (v22)

Revision 22 of this benchmark created by Rogalik on


Setup

var a = "10";

Test runner

Ready to run.

Testing in
TestOps/sec
Call
(function(format) {
    //var params = Array.prototype.slice.call(arguments, 1), 
        chunks = format.split(/\${\d+}/);
    for (var i = chunks.length - 1; i > 0; i--)
        //chunks.splice(i, 0, params[i - 1]);
        chunks.splice(i, 0, arguments[i]);
    return chunks.join('');
})("Video - Live - coming in ${0}", 4);
ready
Apply
(function(format) {
    var params = Array.prototype.slice.call(arguments, 1), 
        chunks = format.split(/\${\d+}/);
    for (var i = chunks.length - 1; i > 0; i--)
        //chunks.splice(i, 0, params[i - 1]);
        chunks.splice(i, 0, params [i-1]);
    return chunks.join('');
})("Video - Live - coming in ${0}", 4);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.