The real is this slower than var test

Benchmark created by Zohaib Sibt-e-Hassan on


Description

Fixed version of is this slower that var test

Preparation HTML

<script>
  var Template = function(name) {
   this.name = name;
   this.one = {
    two: {
     three: name,
     foo: 1,
     bar: 1,
     baz: 1,
     quux: 1
    },
    foo: 1,
    bar: 1,
    baz: 1,
    quux: 1
   };
  
   var privatName = name;
   this.getVar = function() {
    var name = 'Ryan';
    return name;
   };
  };
  
  Template.prototype = {
   getName: function() {
    return this.name;
   },
   getDeep: function() {
    return this.one.two.three;
   }
  };
  
  var obj = new Template('Ryan');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Get var test
obj.getVar();
ready
Get using this test
obj.getName();
ready
Get using this deep
obj.getDeep();
ready

Revisions

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

  • Revision 1: published by Zohaib Sibt-e-Hassan on