I want to override a member function in constructor function not the whole constructor function but only one member function inside it, my constructor function look like
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");
}
};
}
and in override.js i want to override it like this
viewModel.prototype.testFuncA = function(){
console.log("you are in overrided function test funcA");
}
and when i create object of viewModel constructor function
var obj = new viewModel();
obj.testFuncA();
then output should be you are in overrided function test funcA, but it print you are in not overrided function test FuncA which is not my desire output how may i achieve desire output.
When only core.js file is loaded in my web page then the testFuncA will output as you are in not overrided function test FuncA but when i load both files, that is core.js and after that override.js then testFuncA will output you are in overrided function test funcA.
selfin this piece of code is local toviewModelscope, you can't access them in an outer scopeself = thisis overridden byself = { /* … */}, soselfbecomes totally private as mentioned by Hacketo. Only objects defined within that constructor will be able to useself.