Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// 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');
Add Comment
Please, Sign In to add comment