My experience working with jQuery (and JavaScript before it) is that prototypical inheritance isn't as useful as I was expecting. It has uses, but it's not fundamentally important to the language.
In Javascript if you want to return an object with a method foo
:
return {
foo: function() {
alert('You called foo!');
}
};
And callers can treat such objects as polymorphic - that is, they can call foo
without worrying about what "type" of object it is. There is no need for inheritance.
Against this background, prototypes are merely an optimisation. They allow you to create a large number of objects without having to replicate a big set of function properties in each instance. This is why jQuery uses it internally. A jQuery object has dozens of functions, and it might be a major overhead to copy them into every instance.
But from the perspective of a user of jQuery, prototypes aren't particularly important. It could be rewritten to not use them and it would still work (but might use a lot more memory).