Home » Javascript » How to access a function embedded into another function from an external javascript file?

How to access a function embedded into another function from an external javascript file?

Posted by: admin August 19, 2018 Leave a comment

Questions:

My apologies if this question have already been asked but for some reasons , I can not find pertinent answers.

so I have a script X.js that have two functions : function B embedded into a main function A , and an outside script Y.js that contains function C. Both scripts are located into the root folder.

script X.js

function A () {
  // code here ....

  function B () {
  // code here need to be accessed by function C () in script Y
  }

}

script Y.js

function C () {
  //code in function C that need to work with input from function B ...
}

My question is how can I get the output of function B directely into function C () that is located in script Y.js ?

Answers: