js如何要让一个对象继承另一个对象的原型属性和方法
1、使用 Object.create()
const parent = {
greet: function() {
console.log("Hello from parent!");
}
};
const child = Object.create(parent);
child.greet(); // 输出: Hello from parent!
2、使用 proto 属性
const parent = {
greet

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



