JavaScript OOP – Why Make JavaScript Class-Based?

javascriptobject-oriented

JavaScript is a prototype language. To turn it into a class based language adds little value? I am not talking about best-practice here. I remember reading an article from way back, which claimed that the class-based worldview is perceivably more flawed than the one of prototypes. My summary can be found here: http://carnotaurus.tumblr.com/post/3248631891/class-based-javascript-or-not. I am resisting to use the class-based jQuery add-on and other attempts at faciliating class-based JavaScript. Peer pressure is strong but is there a stronger theoretical or practical reason why I should stop resisting?

Best Answer

Continue to resist!

JavaScript is fine as is, it just suffers from a few misunderstandings.

  1. It's not Java. It's not even related. The name was chosen to ride on Java's coat tails and it succeeded but fostered the idea that it was somehow a lightweight version of Java.
  2. It's functional. Functions are "first-class citizens". Being comfortable with functional programming will give you a leg up on JavaScript.
  3. It's prototype based. This means you don't have classical inheritance but this gives you greater flexibility to mix and match.
Related Topic