JavaScript 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.
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.
Comments
Avoiding the use of 'new' isn't overengineering, it's idiomatic JS.
It's dogmatic not idiomatic.
JavaScript 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.
That's not accurate; there are actual, technical reasons for avoiding new hence why some advise against using it.
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.
damn, I've been using that word slightly incorrectly for years, and now I hate myself. Thanks.
Whoa a pleasant exchange on the internet. Yay.
What are the technical reasons to avoid using new?