Skip to content
Advertisement

Tag: prototypal-inheritance

JavaScript: ‘this’ in superclass refers to subclass

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 registered types. The types are registered from properties, or

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 example. He adds a simple getter to Object and everything

Advertisement