I saw a video in which Crockford told us not to use the new
keyword. He said to use Object.create instead if I\'m not mistaken. Why does he tell us not to use
Crockford discusses new
and Object.create
in this Nov 2008 message to the JSLint.com mailing list. An excerpt:
If you call a constructor function without the
new
prefix, instead of creating and initializing a new object, you will be damaging the global object. There is no compile time warning and no runtime warning. This is one of the language’s bad parts.In my practice, I completely avoid use of
new
.