var foo = {
bar: function() { return this.baz; },
baz: 1
};
(function(){
return typeof arguments[0]();
})(foo.bar);
Why does this code return undefined?
I would assume arguments[0] would hold the foo.bar, which is a function. When invoked via arguments[0]() it should return the result of the function evaluation in, this case 1. Hence, typeof arguments[0]() should return “Number” (like typeof 1). Instead, it returns undefined. Why?
this refer to bar function itself.
fiddle : http://jsfiddle.net/W9Jqb/