Let's say I have a function in a namespace like:
app.MyNamespace = {
defaults: {
myOption: 1
},
myFunction(param1, param2, options){
options = $.extend(options, this.defaults);
}
}
then if I call this in some other context (e.g. window) with
app.MyNamespace.myFunction.call(this);
obviusly the options does not extend with the defaults because it loose the right context.
How can I mantain the defaults in the function, but calling it in another context?
app.MyNamespace.myFunction.call(this);why would you call it like that?myFunctionyou add.bind(this);