Just uninstall var
var a = "declared variable"; var fc = function () { console.log(a); }; (function () { a = "hello world"; fc(); }) ();
The var parameter defines the variable in the current scope.
In response to editing, the only way to access an area should be in it (or pass it as an argument). Since you do not want to transmit it, this is the only other option that I see.
var a = "declared variable"; (function () { var fc = function () { console.log(a); }; var a = "hello world"; fc(); }) ();
Or, if you want to pass an area along such a construction, how it works
var a = "declared variable"; var fc = function (scope) { console.log(scope.a); }; (function () { this.a = "hello world"; fc(this); }).apply({});
From a technical point of view, this is not the scale that you are passing, but it will be so.
source share