F.call (null, x) vs f (x) speed

Guys, I would like to get a theoretical answer to this question.

I would like to know if calling f.call (null, x) can be slower than calling f (x) ?

+3
source share
2 answers

Yes, it will be very slightly slower due to the search for add properties (search for a member callin a function f). This is a very micro-optimization, and not something that should turn you off, using call()when necessary.

, , , bind(), , , , call(), . , .

, - http://jsperf.com.

+2

, , .

 function foo(x) {
  for (var i = 0; i < 100; i++);
 }

 // Tests
 foo('Bob');
 foo.call(null, 'Fish');
 foo.call(window, 'Cowboy!');
+5

All Articles