I am calling a superclass method from a subclass. When called from a subclass, ‘this’ in the superclass method no longer refers to the superclass but to the subclass that called it. This creates problems with inheritance. Details as follows: In my project I use a class to construct objects from re…
Tag: prototypal-inheritance
Concatenative inheritance vs class inheritance in JavaScript
concatenative inheritance works like a composition to me when I look to it at the beginning, but people keep naming it as an inheritance. classes, however, use the prototype to create a prototype chain that connects objects together. the question now is, if both concatenative inheritance and class inheritance…
Why is extending native objects a bad practice?
Every JS opinion leader says that extending the native objects is a bad practice. But why? Do we get a perfomance hit? Do they fear that somebody does it “the wrong way”, and adds enumerable types to Object, practically destroying all loops on any object? Take TJ Holowaychuk’s should.js for …
Node.js / Express.js – How to override/intercept res.render function?
I’m building a Node.js app with Connect/Express.js and I want to intercept the res.render(view, option) function to run some code before forwarding it on to the original render function. It looks like a contrived example, but it does fit in an overall framework I’m building. My knowledge of OOP an…