Re: [問題] json function prototype

作者: icydream (巧虎)   2015-12-24 19:46:07
※ 引述《qas612820704 (Lego)》之銘言:
: var Item = {
: list: function() {
: var obj = function() {};
: obj.prototype.sayHello = function() {console.log('Hello')};
: return obj;
: },
: };
: var a = new Item.list();
: 我想請問 為何 我沒辦法 call 到 a.sayHello()
: 我不知道這該怎下關鍵字去 google 有大大可以解答媽QQ~
建議可改成
var Item = {
list: function() {
this.constructor.prototype.sayHello = function() {console.log('Hello')};
}
};
var a = new Item.list();
a.sayHello();

Links booklink

Contact Us: admin [ a t ] ucptt.com