I have come across this programming style where: Instead of calling an object method directly, they pass in its constructor method a string, the constructor method then check this string and call the function associate with it.
function MySimpleObject(option){
if (typeof option === 'String'){
pluginMethods[String].apply(this, arguments);
}
else {
init();
}
}
This seem to be used with jQuery as extend function a lot.
jQuery.fn.extend({simpleObj: MySimpleObject});
I would really appreciate if someone could enlighten me on this.