re: Why JavaScript is an OOP Language (Even Though It Doesn't Have Classes) VIEW POST


JS is object-oriented, yes. But it isn't class-oriented. The fact that there is a prototype chain is usually not very relevant in practice, but when it does make a difference, it's going to bite you in places you never realized that problems could emerge there. In particular modern web frameworks (React, Redux...) have shown how OOP is used in JavaScript, which is: not at all. 99% of the time you work with plain objects (as in: prototype is object, no methods, only public fields). If you receive a JSON string from an Ajax call, what do you do? Json.parse(...) it. Do you perform any DTO transformation? Or even set a prototype? Nah, too much of a hassle, "let's just use the data". To me this is a strong indication that OOP in JavaScript has way too many hassles and quirks.

With ES6, there was the opportunity of a lifetime: the introduction of a "class" keyword. But instead of starting from a clean table and performing a breaking change, classes are being faked while prototype chains are still merrily working in the background, except that there is now even more confusion among developers than before. Yikes.

Code of Conduct Report abuse