将函数的值获取到变量

时间:2018-11-12 07:42:31

标签: javascript

之后

console.log(myvar())

我希望看到“ george”,因为我希望函数能够被执行。我在这里想念什么?

 var person = {
 name: "george",
 getName: function ()
{
    return this.name;
},
 numbers: [7, 11, 41]
};

myvar = person.getName;
console.log(myvar); //prints function as a string as expected
console.log(myvar()); //

0 个答案:

没有答案