Is there any way to clean up all the Obj.prototype.field = statements in my javascript code? I am using jQuery. I want to do the same thing except not have every other word in my code be prototype. Maybe what I’m asking is impossible — if so, just let me know and that will be the answer.
I found this to be an ungoogleable question because there is a js library named “Prototype”…
Use jQuery.extend. The properties of the second argument will be copied over to the first one:
This is what jQuery uses internally, jQuery.fn being an alias for jQuery.prototype: