0
var oldobj = {
firstm: function() { console.log("firstm"); },
secondm: function() { console.log("secondm"); }
};
var newobj= Object(oldobj);
newobj.thirdm = function() { console.log("thirdm"); };
oldobj.fourthm = function() { console.log("4thm"); };
newobj.fifthm = function() { console.log("5thm"); };
oldobj.fifthm(); // logs "5thm" in console
根據原型繼承,oldobj沒有鏈接到newobj函數。但在上面的例子中,oldobj如何訪問newobj的fifthm()?原型繼承未按預期工作
你迷惑'對象()'和'的Object.create()'? –