Javascript view all page variable in console

April 5, 2017

If you want to see all the javascript variables set in the page via the console you can use the following function.

 

<pre class="brush: javascript; gutter: false">function showNonNatives ()

{

   var _arrHits = []

   for(var b in window)

   { 

       if(window.hasOwnProperty(b))

       {

           //console.log(b);

           try{_arrHits.push(b + &quot; = &quot; + window[b]);}catch(e){};

       }

   }

   return _arrHits;

}</pre>

 

Here is a screenshot of how to run the function in the console

 

 

 

If you have any suggestions on how to improve this please contact us. 

Share on Facebook
Share on Twitter
Please reload

Recent Posts