Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133
Mac OS X 10.15.7
Desktop
25 days ago
Test name Executions per second
direct call 222831.0 Ops/sec
bind 227481.4 Ops/sec
call 225925.9 Ops/sec
apply 223383.6 Ops/sec
method call 213645.9 Ops/sec
Script Preparation code:
AخA
 
function test(msg) {
  console.log(this, msg);
}
function test1(self, msg) {
  console.log(self, msg);
}
function test2(msg) {
  console.log(this, msg);
}
function test3(msg) {
  console.log(this, msg);
}
function test4(msg) {
  console.log(this, msg);
}
String.prototype.test5 = function(msg) {
  console.log(this, msg)
}
Tests:
  • direct call

     
    test1("World", "Hello");
  • bind

     
    test2.bind("World", "Hello")();
  • call

     
    test3.call("World", "Hello");
  • apply

     
    test4.apply("World", ["Hello"]);
  • method call

     
    "World".test5("Hello")