Re: [問題] json function prototype
※ 引述《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();
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 219.70.202.200
※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1450957569.A.0F0.html
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章