Scope vs this

Benchmark created by Blaine on


Setup

var a = {};
    a.val = 1;
    a.test1 = function(){
    return a.val;
    };
    a.test2 = function(){
    return this.val;
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Scope
a.test1();
ready
This
a.test2();
ready

Revisions

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