I am trying to add an inner function to the function and invoking that child function from another function.
My function driver code is as below which i cannot modify:
const obj = function1();
obj.method1(soemobject);
The definition for the function1() which is already present is as below:
function function1(){
}
What I want to achieve is adding a method inside function1 so that i can call it from another function:
function function1(){
function method1(item){
console.log(item)
}
}
The error I am getting is:
with the code chunk
function function1(){
function method1(item){
console.log(item)
}
this.method1 = method1
}
and
with the code chunk
function function1(){
function method1(item){
console.log(item)
}
}
What I have tried so far is:
- Making it a constructive function: But as the driver code cannot be modified, this won't work as it needs to be called with a new keyword.
- Tried accessing function1's properties using this keyword, no luck.

