const obj = {
name: 'JSPrep',
greet: () => console.log('Hi from ' + (this && this.name)),
};
obj.greet();const obj = {
name: 'JSPrep',
greet() { console.log('Hi from ' + this.name); },
};
obj.greet();Bug: Arrow functions inherit this from the enclosing lexical scope. At the module level this is undefined — not obj.
Explanation: Regular method shorthand greet() { } has its own this, correctly set to obj when called as obj.greet().
Key Insight: Never use arrow functions as object methods that rely on this. Use method shorthand instead.