我是JS的新手,我在代碼下面寫道,但是我得到了錯誤「Prototype is not defined」。JS原型錯誤「Prototype is not defined」
var proto = {
describe: function() {
return 'name: ' + this.name;
}
};
var obj = {
[[Prototype]]: proto, //error in this line
name:'obj'
};
console.log(proto.describe());
console.log(obj.describe());
[原型]是一個內部的財產,不是有效的名稱爲關鍵。你想使用'Object.create' – Bergi