3 ms·
Avoiding the use of 'new' isn't overengineering, it's idiomatic JS.
by couchand 12y ago
Avoiding the use of 'new' isn't overengineering, it's idiomatic JS.
- davedx 12y agoIt's dogmatic not idiomatic.
- couchand 12y agoJavaScript code rarely uses inheritance because it's completely out of place. Most non-trivial JS apps I've worked on make heavy use of duck-typing polymorphism. It works great because you don't need to deal with arcane class hierarchies: just make sure the object has what it needs to get its own job done. Using a constructor in the first place in a language that really doesn't need them is what's dogmatic.
- BinaryIdiot 12y ago> It's dogmatic not idiomatic. That's not accurate; there are actual, technical reasons for avoiding new hence why some advise against using it.
- phpnode 12y agoThere are equally valid technical reasons for using `new`, so it's dogma
- BinaryIdiot 12y ago> There are equally valid technical reasons for using `new`, so it's dogma I really don't want to get into this argument but that's not what dogma means. Dogma is something that comes from an authority as being undeniable but saying you can't or shouldn't use new isn't undeniable, it's deniable as you said yourself there are valid reasons for using new. and now I hate myself. Thanks.
- phpnode 12y agodamn, I've been using that word slightly incorrectly for years, and now I hate myself. Thanks.
- BinaryIdiot 12y agoWhoa a pleasant exchange on the internet. Yay.
- davedx 12y agoWhat are the technical reasons to avoid using new?