Skip to content

Comment on Stop Using Constructors in JS (2012)parent

Comments

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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.