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?

  • i don't know...why did u stop resisting? perhaps Mootools can help
    – KJYe.Name
    Commented Feb 15, 2011 at 18:54
  • 4
    I was under the impression this language change is done primarily because many developers don't grasp the intricacies of prototypical object-orientation. And maybe a class-based model can more rigidly restrict the inheritance tree.
    – mario
    Commented Feb 15, 2011 at 22:09
  • @mario Sounds about right to me
    – Phil Helix
    Commented Jan 1, 2012 at 10:57

3 Answers 3


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.
  • Regarding your point #1, it's actually the other way round: Sun paid Netscape to change the name because they wanted Java to ride LiveScript's coat tails, not the other way round. Java in the browser was a failure, even back then, there simply was no coat tail to ride for Netscape ;-) Commented Aug 18, 2012 at 12:54

Recently I discovered the reasoning behind prototype based versus class based object oriented languages. I always thought that prototypes make no sense, because sooner or later you will find out your objects are in some way similar and you can group them, create hierarchies and use polymorphism... I think the point is to understand, that with prototypes, the language itself is more flexible - you could for instance implement contracts, aspect oriented programming and all sorts of metaprogramming much easier. You could create smarter interfaces, components with dependency resolution and much more... I think prorotypes are a bettter language feature, but one has to remember, that classes are needed and there should be a library for them.


You shouldn't care whether your JavaScript is class based or prototype based. The important question is how to make your program object oriented. Since the DOM plays the central role in websites/web-applications you could focus on making the DOM nodes object oriented instead. See for example this demo (implemented using the Entwine library):


  • JavaScript is already object oriented... I'll have a play around with this UI in a bit. I can swap different jQuery libraries in and out? It looks fun.
    – Carnotaurus
    Commented Feb 15, 2011 at 19:16
  • 1
    JavaScript is a language that enables you to implement a website/web-application in an object oriented way. But writing in JavaScript does not automatically make your program object oriented.
    – Erik
    Commented Feb 15, 2011 at 19:21
  • And yes you can swap libraries in and out using jsfiddle.
    – Erik
    Commented Feb 15, 2011 at 19:22
  • Also Alan Kay (who coined the term 'Object-oriented') has the following to say about class vs. protype based OO: userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en
    – Erik
    Commented Feb 15, 2011 at 19:40
  • 2
    If you're only using the OO part of JS, as awesome as it may be, you're not using the whole language. No need to ignore that bit of functional programming you have available.
    – user7043
    Commented Feb 16, 2011 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.