I have this code ...
function a(options) { for (var item in options) { if ( ! options.hasOwnProperty(item)) { continue; } this[item] = options[item]; } } a({ 'abc': 'def' });
jsFiddle .
While this decompresses the variables from the object, it sets them to the global scope (bound to window ), because this is window in this case.
So, after the function, I can do alert(abc) , and it will warn def , which is bad.
How can I set the scope of variables for this function?
source share