Is JavaScript 's "new" Keyword Considered Harmful?

Posted by Pablo Fernandez on Stack Overflow See other posts from Stack Overflow or by Pablo Fernandez
Published on 2008-12-20T15:20:07Z Indexed on 2010/03/19 3:41 UTC
Read the original article Hit count: 403

Filed under:
|

In another question, a user pointed out that the new keyword was dangerous to use and proposed a solution to object creation that did not use new... I didn't believe that was true, mostly because I've used Prototype, Scriptaculous and other excellent JavaScript libraries, and everyone of them used the new keyword...

In spite of that, yesterday I was watching Douglas Crockford's talk at YUI theater and he said the exactly same thing, that he didn't use the new keyword anymore in his code.

Is it 'bad' to use the new keyword? what are the advantages and disadvantages of using it?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about best-practices