JavaScript ini dalam fungsi dalam

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();
SAMER SAEID