Currently i’m working on a jquery plugin and looking at other plugin code i found a common way to write it passing throught an object, somethng like :
$.fn.myplugin = function(method){
//... some code
object = new $.myobject(param);
//... other code
// myobject definition
$.myobject = function(param){
//.... my object code
}
}
I can’t understand how works $.myobject definition and why many developers use it to define their plugins.
Could you give some info and tutorial/links to documentation if possibile ?
The ability to add properties at runtime to javascript objects is what makes every javascript object an ‘expando’ object.
There is an explanation here
Stack overflow question on javascript expando objects
Hope this helps 🙂