Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
/// Run this code in any browser
function RegularConstructor () {
}
RegularConstructor.prototype = {
meth1: function(){},
meth2: function(){},
meth3: function(){},
meth4: function(){},
meth5: function(){},
meth6: function(){},
meth7: function(){},
meth8: function(){},
meth9: function(){}
};
function crockfordsIdea () {
var inst = {
meth1: function(){},
meth2: function(){},
meth3: function(){},
meth4: function(){},
meth5: function(){},
meth6: function(){},
meth7: function(){},
meth8: function(){},
meth9: function(){}
};
return inst;
}
var n = +new Date;
for (var i = 0; i < 10000; ++i ) {
crockfordsIdea();
}
alert('crockfordsIdea :' + (+new Date - n) + 'ms');
var n = +new Date;
for (var i = 0; i < 10000; ++i) {
new RegularConstructor();
}
alert('RegularConstructor :' + (+new Date - n) + 'ms');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.