Skip to content

Instantly share code, notes, and snippets.

@uhop
Created January 18, 2011 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uhop/784134 to your computer and use it in GitHub Desktop.
Save uhop/784134 to your computer and use it in GitHub Desktop.
Creating simple objects.
// Creating simple objects.
// our constructors
var A = function(){};
var B = function(){};
B.prototype.m = function(){};
var C = function(){
this.p = 42;
};
C.prototype.m = function(){};
this.group(
"Objects",
function EmptyNaked(){ return {}; },
function EmptyObj() { return new Object(); },
function EmptyCtrA() { return new A(); },
function EmptyCtrB() { return new B(); },
function PropNaked() { return {p: 42}; },
function PropCtrC() { return new C(); }
);
@uhop
Copy link
Author

uhop commented Jan 18, 2011

Benchmark it with http://www.perfjs.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment