1

I have tried to find all Global Variable available in my site. To avoid memory leak issue I am planning to dump all global variable to limited scope.

But I am not able to find any generic function when I can find all global variables created in files.

For Example:

<script>
    var abc = 3;
    var xyz = 5;
</script>

I have to manually find like this:
enter image description here

OR
enter image description here

I have tried to use Object.keys( window );, but it returns all variables which are provided by browser and core JavaScript also.

I wanted only those variable which are declared in JavaScript files.

Dharam Mali
  • 907
  • 1
  • 11
  • 24
  • 1
    Why don't you just wrap all your code in an [IIFE](https://stackoverflow.com/questions/8228281/what-is-the-function-construct-in-javascript)? – George May 23 '17 at 09:42
  • It's very old code (not developed by me), and exchanging value to another file by declaring global values (which is also not recommended by me also). And there are plenty of variable which are declared globally. If I limit their scope may be chances to code break. – Dharam Mali May 23 '17 at 09:47

0 Answers0