Guest User

Untitled

a guest
May 16th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. /// Run this code in any browser
  2.  
  3. function RegularConstructor () {
  4.  
  5. }
  6.  
  7. RegularConstructor.prototype = {
  8. meth1: function(){},
  9. meth2: function(){},
  10. meth3: function(){},
  11. meth4: function(){},
  12. meth5: function(){},
  13. meth6: function(){},
  14. meth7: function(){},
  15. meth8: function(){},
  16. meth9: function(){}
  17. };
  18.  
  19. function crockfordsIdea () {
  20. var inst = {
  21. meth1: function(){},
  22. meth2: function(){},
  23. meth3: function(){},
  24. meth4: function(){},
  25. meth5: function(){},
  26. meth6: function(){},
  27. meth7: function(){},
  28. meth8: function(){},
  29. meth9: function(){}
  30. };
  31. return inst;
  32. }
  33.  
  34.  
  35. var n = +new Date;
  36.  
  37. for (var i = 0; i < 10000; ++i ) {
  38. crockfordsIdea();
  39. }
  40.  
  41. alert('crockfordsIdea :' + (+new Date - n) + 'ms');
  42.  
  43. var n = +new Date;
  44.  
  45. for (var i = 0; i < 10000; ++i) {
  46. new RegularConstructor();
  47. }
  48.  
  49. alert('RegularConstructor :' + (+new Date - n) + 'ms');
Add Comment
Please, Sign In to add comment