I have this code...
function a(options) {
for (var item in options) {
if ( ! options.hasOwnProperty(item)) {
continue;
}
t
You can access the function from inside itself using the callee property:
function a(options) {
var thiz = arguments.callee;
for (var item in options) {
if (!options.hasOwnProperty(item)) {
continue;
}
thiz[item] = options[item];
}
}
a({
'abc': 'def'
});
alert(a.abc);
Alternatively, you can set the scope when you call it:
function a(options) {
for (var item in options) {
if (!options.hasOwnProperty(item)) {
continue;
}
this[item] = options[item];
}
}
a.call(a, {
'abc': 'def'
});
alert(a.abc);