4 ms·
What they describe there is not necessary. You can use the built-in Object.create function. The code shown at the bottom can be used in case you are using a old
by zzo38computer 2y ago
What they describe there is not necessary. You can use the built-in Object.create function. The code shown at the bottom can be used in case you are using a old version of JavaScript that does not have Object.create.
Like they say, there are many benefits of prototype inheritance compared with class inheritance, and I agree with that.
I think that it is not a good idea to affect Object.prototype, and I think it might have been a bad idea even to put anything there at first when they invented JavaScript. (For this reason, sometimes Object.create(null) is used, which creates an object with no prototype.)
- ramesh31 2y ago> What they describe there is not necessary. You can use the built-in Object.create function. What they describe there was the inspiration for the existence of Object.create. This is a historical post from Crockford, the godfather of JS.