[jquery] xxx.fn.funtionName() {} is prototype

Prototype

All objects have a prototype property. Whenever the interpreter looks for a property, it also checks the prototype. jQuery uses that extensively to add methods to jQuery instances.

var form = $(“#myform”);
form.clearForm; // undefined
form.fn.clearForm = function() {
return this.find(“:input”).each(function() {
this.value = “”;
}).end();
};
form.clearForm() // works for all instances of jQuery objects, because the new method was added to the prototype

(This example needs clarification: how does it modify the prototype when the word “prototype” doesn’t appear anywhere? The implication is that form.fn is simply an alias for form.prototype, but if that’s the case then it should be explained. :-?)

In javascript:the definitive guide 5 edition,dont add attibute to Object.prototype