Hacker News new | ask | show | jobs
by Kiro 4331 days ago
OT but I'm looking at jQuery and can see that some methods are defined on the jQuery object and some on jQuery.prototype. What's the rationale? Why not define all methods on the prototype?
1 comments

The ones in jQuery are a bit like static methods in classical OO languages. A JQuery instance encapsulates a set of nodes, so methods that don't apply to nodes are on the JQuery object and not the prototype.