3 ms·
Yes, this is it. The MOP approach basically involves using ‘Object.assign’ to instantiate new objects from the metaobject. It is quite straightforward in my opi
by lobstrosity420 3y ago
Yes, this is it. The MOP approach basically involves using ‘Object.assign’ to instantiate new objects from the metaobject. It is quite straightforward in my opinion, but that is relative I suppose. I don’t know if this is true but I’ve been told that Brendan Eich intended for this exact approach to be the one and true OOP in JS, but was persuaded by his boss to implement constructor functions to make it more like Java.
- moron4hire 3y agoThat'd be a little weird if that was Eich's "original vision" considering `Object.assign` didn't come out until ES6. Which was also when the `class` keyword was introduced.
- lobstrosity420 3y agoGood catch. It’s been a while since I’ve been thought the ways of old JS so I’m misremembering. It’s all apocryphal anyhow.
- BrendanEich 3y agoIt's not apocryphal if I'm the source. I wanted Self-ish prototypes and cloning but "Make It Look Like Java" orders trumped my wishes.