function direct call vs call() vs bind()

JavaScript performance comparison

Test case created by Chris Yip

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var person = {
    firstname: 'John',
    lastname: 'Smith'
  };
  
  function direct_call (args) {
    return args.firstname + ' ' + args.lastname;
  }
  
  function binded_call () {
    return this.firstname + ' ' + this.lastname;
  }
  
  var binded = binded_call.bind(person);

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
direct call
direct_call(person);
pending…
call()
binded_call.call(person)
pending…
bind()
binded()
pending…

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

Compare results of other browsers

0 Comments