Douglas Crockford 就 ES6 的“The Better Parts”发表了精彩的演讲。除此之外,他 encourages a move away from prototypal inheritance in favor of class free OOP .
他在这里说他停止使用 new
、Object.create
和 this
,但并没有真正解释替代方案。任何人都可以告诉我它的外观吗?
最佳答案
你应该观看整个视频,他在 later in the video 上解释说.
function constructor(spec) {
let {member} = spec,
{other} = other_constructor(spec),
method = function () {
// accesses member, other, method, spec
};
return Object.freeze({
method,
other
});
}
关于javascript - Douglas Crockford 谈 JavaScript 中的 Class Free OOP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27595749/