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 |
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)
}
test1("World", "Hello");
test2.bind("World", "Hello")();
test3.call("World", "Hello");
test4.apply("World", ["Hello"]);
"World".test5("Hello")