As shown below, the method() will output hello,undefined. What is the scope of the method()? Thank you.
var obj = {
name:'Tom',
sayHello:function() {
console.log("hello," + this.name);
}
}
obj.sayHello();
var method = obj.sayHello;
method();
output
hello,Tom
hello,undefined