I am trying to figure out the difference between undefined and not defined. So below is one simple program.
var name = 'John';
var age = 30;
var obj = {
//name: 'Joe',
age: 29,
getInnerName: function() {
return this.name;
},
getOuterName: () => {
return this.name;
}
}
console.log(obj.getInnerName()); //undefined
console.log(obj.getOuterName()); John
My doubt is, why first console.log writes undefined and not the error -> Uncaught ReferenceError: name is not defined?
Explanation is appreciated!
PS - Please correct the question If I fail to convey What I meant.