I am looking to modify a specific member function within a constructor function without affecting the entire constructor. Here is an example of my current constructor function:
function viewModel(){
var self= this;
self = {
testFuncA:function(){
console.log("you are in not overrided function test FuncA");
},
testFuncB:function(){
console.log("you are in not orverided function test FuncB");
}
};
}
In the file override.js
, I want to override it like so:
viewModel.prototype.testFuncA = function(){
console.log("you are in overrided function test funcA");
}
When creating an object of the viewModel
constructor function:
var obj = new viewModel();
obj.testFuncA();
The desired output should be you are in overrided function test funcA. However, currently it prints you are in not overrided function test FuncA. How can I achieve the desired output?
When only the core.js
file is loaded on my web page, the testFuncA
will output as you are in not overrided function test FuncA. But when both files are loaded - first core.js
and then override.js
- then testFuncA
will output you are in overrided function test funcA.