I am trying to understand why this snippet of code logs the string 'Bob says hi'
immediately and does not wait the expected time.
var name = "Window";
var alice = {
name: "Alice",
sayHi: function() {
console.log(this.name + " says hi");
}
};
var bob = { name: "Bob" };
setTimeout(alice.sayHi.call(bob), 1000);
What is making the setTimeout
function not execute after the wait argument?
The question has been marked as duplicate. Yet I don't see it being identical. This question is using call but the one referenced is not.