So...I've been programming for 40 years, from machine language to C++ to Javascript/Typescript. Last 10 years heavily in Javascript.
I seem to stumble when asked about prototypical vs. classical inheritance. I keep reading articles, I keep trying to rehearse, but...honestly, I feel like I understand the concepts but don't know how to give interviewers what they want.
C++ is my frame of reference for classical inheritance (as well as Java and C# which I've also programmed in). Here inheritance is static - you create an object from a class, and that's that.
Javascript is of course dynamic. You create an object which has a prototype that itself has a prototype, and those prototypes have methods and properties which can be extended at runtime and will be available to all objects that share that prototype chain.
Ok, cool.
I understand all that. But I can't seem to give interviewers what they want to hear. In all honesty, I use class
and extends
and Typescript interfaces and while I know it's different under the hood, the only real practical difference I experience is that you can modify prototypes at runtime for things like polyfills (implementing missing functionality).
So...help. I feel like the knowledge is all in my head, but I don't know how to convey it properly.