Can someone help me out with the code below:
function returnObj(){return this}
a = {
name: "Eva",
age: "12",
getContext: returnObj
}
a.getContext // logs Object{name:"Eva", ...} which is fine.
But when I try
a = {
name: "Eva",
age: "12",
getContext: function(){
returnObj();
}
}
a.getContext // logs undefined.
Can someone please help me understand what is going on here, and show me how I can make the 2nd piece of code return the object that called the function when I call a.getContext()
just like the 1st one did.