Hello. How to extend the functionality of the method (function). For example, there is a certain class (function)
MyFunction = function() { this.myMethod = function() { //некие вычисления } }
How can I make sure that when the myMethod
function is myMethod
, the commands that are executed inside it, plus a few more? It is also necessary that everything inside the function (class) MyFunction
remains unchanged (that is, not to edit the code inside MyFunction
).
UPD1 :
If in other words to describe:
There are about fifty classes. In each of these classes there is a method called initData
, which performs each of its operations. All these classes have the same superclass (all fifty classes extend the functionality of a single class (function)). It took me to all classes, to each method, to add several more identical operations. Is it possible? If so, how?
UPD2 :
There is one class
MySuperclass = function() { //некоторые методы }
There are a number of subclasses of this type:
MySubclass1 = function() { //Некоторые методы, переопределяющие родительские //Плюс метод initData: this.initData = function() { //Содержание метода /* Основная проблема состоит в том, что я тут не указывал конструкцию вида MySubclass1.superclass.initData.apply(this, arguments); */ } } //
I need to override all initData
methods in subclasses. If it is still unclear what should be done, ask.
UPD3 :
All subclasses inherit their superclass. how this happens, I dropped because of uselessness.