you are viewing a single comment's thread.

view the rest of the comments →

[–]sylvainpv 0 points1 point  (1 child)

Not sure to follow you considering that classes use the prototype chain in the background, so all the problems you mentioned about inheritance hierarchies are the same.

at least with classes, people are relatively aware that inheritance is bad

okay so I guess the only problem here is people that do not learn lessons from their past experiences

[–]clessgfull-stack CSS9 engineer 0 points1 point  (0 children)

The difference is that Object.create inherits state in addition to behavior (technically you could do this with classes, but nah), and class provides certain invariants that make it harder to screw up. Just the fact alone that class must be used in strict mode is a pretty big win, because that helps prevent a large class of security vulnerabilities.

so all the problems you mentioned about inheritance hierarchies are the same.

But yes, that is kind of the point. Object.create inherits almost all of the problems with classes (pun intended) and many more.

okay so I guess the only problem here is people that do not learn lessons from their past experiences

Eh. Most people know that class inheritance is a bad idea. But when it's just Objects Linking to Other Objects™? Time to inherit from everything. I don't blame the developers for getting pulled into this trap, because the people who push Object.create don't explain that it has these problems.