Douglas Crockford on Class Free OOP in JavaScript

后端 未结 1 423
误落风尘
误落风尘 2020-12-04 09:30

Douglas Crockford has a really good talk on \"The Better Parts\" of ES6. Among other things, he encourages a move away from prototypal inheritance in favor of class free OOP

相关标签:
1条回答
  • 2020-12-04 09:54

    You should watch the whole video, he explains it at 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
      });
    }
    

    It's the revealing module pattern returning a frozen object.

    0 讨论(0)
提交回复
热议问题