У меня есть IIFE с вложенной функцией внутри. Внутри и снаружи вложенной функции есть переменная word
. Как я могу получить доступ к переменной word
вне вложенной функции, а не внутри?
Код:
(function (){
let word = "Hello";
function sayHello(){
let word = "Greetings";
console.log(word + " Everyone!"); // This is using the inside word variable instead of the outside one. How can I specify JS to use the outside one instead?
}
sayHello();
})();