function name(firstName,lastName){
function getFullName(){
console.log(firstName,lastName);
}
getFullName();
}
name('Jaw Jaw', 'Rakhaine');
//Output will be
//Jaw Jaw Rakhaine
const person = {
name : 'Jack',
age: 25,
// this inside method
// this refers to the object itself
greet() {
console.log(this); // {name: "Jack", age ...}
console.log(this.age); // 25
// inner function
function innerFunc() {
// this refers to the global object
console.log(this); // Window { ... }
console.log(this.age); // undefined
}
innerFunc();
}
}
person.greet();