I have a JavaScript function with the following structure:
function someFunctions() {
this.DOSOMETHING = function(parameters){
//some logic
}
}
This is loaded in another file and instantiated as an object that is then being used:
load('file_containing_someFunctions.js')
var someFunctions = new someFunctions();
function doTheThing(parameters) {
//some logic
someFunctions.DOSOMETHING(parameters)
}
I would like to load another file after the first one which overrides or adds properties to someFunctions() before the object is instantiated.
load('file_containing_someFunctions.js')
load('file_containing_extended_functions.js')
var someFunctions = new someFunctions();
function doTheThing(parameters) {
//some logic
someFunctions.DOSOMETHINGELSE(parameters)
}
How should I define DOSOMETHINGELSE in file_containing_extended_functions.js? Is it possible? It's worth noting that the code is rather old and used in old browsers.