2

We are trying to choose a JavaScript framework for our application.

It's come down to either JQuery or Prototype.

The JQuery has a lot to offer, like animation and effects, also easy traversal and mutation of the DOM. Another strong point of JQuery are the vast number of plugins available.

But it seems that the prototype has a better inheritance model, in that, it allows the developer to easily extend classes.

My personal preference is JQuery, but I would really like to know, would JQuery help me in inheriting/extending classes ?

2
  • Javascript does not have classes. Commented Sep 8, 2011 at 14:29
  • Tomalak: Prototype.js has its own class-based mechanism. Commented Sep 8, 2011 at 14:55

3 Answers 3

3

John Resig, the creator of jQuery, intentionally avoided the need for instantiation (via the new keyword) in jQuery itself. However, he has written a clever script to provide a simple class inheritance model in javascript generally, without relying on any other framework.

I used to use prototype.js, but jQuery has practically become the standard javascript library these days. It is possible to use them together, but prototype.js would represent a lot of overhead if you're just looking for an inheritance architecture. I'd suggest sticking with jQuery, and use John Resig's Class script to implement inheritance where it makes sense for you.

Sign up to request clarification or add additional context in comments.

3 Comments

John Resig, the creator of jQuery, intentionally avoided the need for instantiation (via the new keyword) in jQuery itself. Why? and how if I want to create a new object?
@hguser: Javascript is kind of quirky when it comes to object-oriented ideas like creating a new object. He recognized that the functionality he wanted to provide with jQuery could be accomplished entirely with methods, without having to create instances of classes, so he decided to avoid the issue entirely for the purposes of the jQuery framework itself. (Read it in his own words at ejohn.org/blog/simple-javascript-inheritance/#comment-299703). That doesn't prevent people using jQuery from creating and instantiating their own classes, though.
I agree. Prototype.js is great, but it lost mindshare and no longer has the critical mass to thrive.
0

jQuery and Prototype are both great JavaScript frameworks that are easily used and extended. It's tough to recommend one over the other without knowing the specific needs of your application.

Comments

0

There are some way to implement inheritance without using either jQuery or prototype. See for example http://ejohn.org/blog/simple-javascript-inheritance/.

So yes you can use jQuery and implement inheritance.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.