var foo = {
bar: function() { return this.baz; },
baz: 1
};
(function(){
return typeof arguments[0]();
})(foo.bar);
Why does this c
You can reffering to foo by this
statement.
You should write a wrapper like below which will very helpfull if will we wanted to change the name of the foo when we will have a lot of function in foo
var foo = {
bar: function() { return this.baz; },
baz: 1
};
(function(a){
for( var i in a){
if( typeof a[i] === "function" ){
a[i] = (function(f){
return function(){
return f.apply(a,arguments);
}
})(a[i])
}
}
})(foo);
(function(){
return typeof arguments[0]();
})(foo.bar);