Master the JavaScript Interview: What’s the Difference Between Class & Prototypal Inheritance?
Eric Elliott
1.6K30

I greatly appreciate this write-up. I know this article was published some time ago, but I’ve been learning Javascript, specifically using Node, and coming from .NET (C# language) I had started exploring class inheritance recently to expand the functionality and reusability of the code in my projects. When I found this article, I quickly grasped the difficulties and pitfalls of trying to implement inheritance using the syntax and structure I was comfortable with in C#; that and what is typically taught in some of the higher-education OOP courses I took. It just makes sense to favor object composition over the “classical” class inheritance structure. JS seems to suffer from the attempts of many to make it more comfortable to developers coming over from different languages and frameworks, especially Java and .NET. As a newbie, I think if you strip that stuff away, hang on to the basics of what you know about OOP while keeping an open mind (and reading articles from the enlightened devs like Mr. Elliot), you can do quite well with JS.

As a side note, I was recently following along with a Pluralsight course that implements class inheritance, and after reading this article and reminiscing on the course, I was able to see where even in the examples given by the instructor, there could be some serious problems, especially in regards to the fragility of the base class.

A single golf clap? Or a long standing ovation?

By clapping more or less, you can signal to us which stories really stand out.