class Name{
constructor(name)
{
this.name = name
}
}
function greet()
{
return "Hello World"
}
let Max = Reflect.construct(Name,["Maxi"],greet);
console.log(Max.__proto__ == greet.prototype); //true
为什么必须覆盖对象原型
答案 0 :(得分:0)
我相信这是你实现ES6课程的一种方式;
class Name{
constructor(name)
{
this.name = name;
}
greet(n){return "Hello " + n;}
}
var Max = new Name("Maxi");
console.log(Max.greet("John"));