3 ms·
Javascript's "prototype" is really Self's "trait". Self prototypes have been replaced by constructors which rather than be normal instances are special construc
by masklinn 7y ago
Javascript's "prototype" is really Self's "trait". Self prototypes have been replaced by constructors which rather than be normal instances are special constructs building instances then setting their prototype property as the (sole) parent to the new instance.
You can partially replicate Self's mechanism by performing a regular shallow-copy (e.g. using `Object.assign(target, source)` then explicitly copying over the prototype (that's fallible as Object.assign only copies the values of enumerable own properties so it's not going to copy the properties themselves).