let user = { firstName: "John", sayHi() { alert(`Hello, ${this.firstName}!`); } }; //using anonymous function setTimeout(function() { user.sayHi(); // Hello, John! }, 1000);
setTimeout(user.sayHi, 1000);
SO Answer says:In the anonymous function, this is bound to the global object (window in a browser environment).
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)