function people(word){ this.word = word; this.say = function(){ console.log(this.word); } this.capacity = function(){ return this.say; } } var p = new people('Hello World'); var res = p.capacity(); console.log(res)//? (){console.log(this.word);} console.log(res())//undefined如上帶嗎,我new了一個people,返回的res 是一個function但是為什么 我執行這個res為undefined,求解,我想的應該打印出來 hello world如果改成這樣呢function people(word){this.word = word;this.say = function(){ console.log(this.word);}()this.capacity = function(){ return this.say;}}var p = new people('Hello World');var res = p.capacity(); //undefined為什么res是undefined
new 關鍵字 return funciton 問題
九州編程
2019-02-18 13:12:16