I have the below structure in file a.js
function factory() {
class A {
constructor() {
}
add(num) {
return num + 1;
}
}
return A;
}
I would like to change the behavior of the "add" method. "add" method would look like below. Addition of 2 instead of 1.
add(num) {
return num + 2;
}
I have created a new file name as b.js
const a = import("a.js");
(new factory()).prototype.add = function(num) {
return num + 2;
}
But it does not change the behavior of the add method inside the "factory" function(a.js file). I would like to change the behavior of the "add" method of the "factory" function(a.js), Could you please provide help or guidance?