new vs literal (v5)

Revision 5 of this benchmark created on


Preparation HTML

<script>
  var o;
  function oNew() {
   var private = 5;
   var privateMethod = function() {
    return private;
   };
  
   this.public = privateMethod;
  };
  function oConstructor() {
   var private = 5;
   var privateMethod = function() {
    return private;
   };
  
   return {
    "public": privateMethod
   };
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
new
o = new oNew();
o.public;
ready
module
o = oConstructor();
o.public;
ready

Revisions

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