Is to disable the global variable in the function that I want.
I would make like Expenssion of Adobe After Effect
example code :
function privateFunction(){
return window;
}
then normally :
result : Window Object
but I want then :
result : undefined
What should I do?
please help me
I want blocking global variable access in function;
Shadow the global variable by a local one:
function privateFunction() {
var window;
return window; // not the Window, but undefined now
}
You need to wrap everything in a closure:
(function() {
var window = 'foo';
function privateFunction(){
return window;
}
console.log(privateFunction());
})();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With