Override Javascript Function Expression

124 views Asked by At

I have a scenario where I want to override/modify the javascript function expression. This is how the function expression looks like.

var func_1 = function func_1(){
  // 300 lines of code
  var func_2 = function func_2(){
     // few lines of code
  };
};

I can access the above function in a different context and want to change the approach of func_2() and it should look like this.

var newfunc_1 = function func_1(){
  // 300 lines of code
  var newfunc_2 = function func_2(){
     // new lines of code
  };
};

How can I achieve this? I believe copy the whole function and modifying will be the worse option.

0

There are 0 answers