I want to show on simple example:
First function:
const Sayhi () {
const Hi = 'Hi';
Say ();
}
Second feature:
const say = () = & gt; {
Console.log (HI);
// How to transfer the value of the variable Hi from the next function?
}
Answer 1, Authority 100%
You can not get the value of a local variable from the adjacent function.
To transfer the parameter, it is necessary, EEE, convey. For example, so:
const sociali = () = & gt; {
const Hi = 'Hi';
Say (HI);
};
const Say = (STR) = & gt; {
Console.log (STR);
};
Answer 2, Authority 67%
To transfer the variable to the second function, you need to use a similar design:
Const Sayhi = () = & gt; {
const Hi = "Hi";
Say (Hi) // We transmit an announced variable from the first function to the second
}
const Say = (Hi) = & gt; {
Console.log (HI)
}
Sayhi ();
const hi = "hi";
will be visible only for the function in which you announced it.
In order to make the variable to be visible for all functions in the file you need to declare it globally for this file. Like this:
const hi = "hi";
Const Sayhi = () = & gt; {
Say (Hi) // Function sees the variable that is not announced in it
}
const Say = (Hi) = & gt; {
Console.log (HI)
}
Sayhi ();
Answer 3
In addition to the previous answer. You can set the global variable var Hi = ‘Hi’; Check that the variable is global through Window.hi; But the level of “purity” of this solution depends on the task.