(function(){
var privateSomething = "Boom!";
var fn = function(){}
fn.addFunc = function(obj) {
alert('Yeah i can do this: '+privateSomething);
for(var i in obj) fn[i] = obj[i];
}
window.fn=fn;
})();
fn.addFunc({
whereAmI:function()
{
alert('Nope I\'ll get an error here: '+privateSomething);
}
});
fn.whereAmI();
whereAmI()がprivateSomethingにアクセスできないのはなぜですか?また、whereAmI()をaddFunc()と同じコンテキストに配置するにはどうすればよいですか?