Explain this: var Bob = { name: "Bob", name_fn: function(){ return this.name; } } console.log(Bob.name_fn()) //"Bob" var fn = Bob.name_fn console.log(fn()) //undefined
Anonymous
when you call fn() its scope is in global. The function call should be scoped properly to work. You should use call or apply to make it work.
Check out your Company Bowl for anonymous work chats.