Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search global variables in JavaScript

Is there any tool or regexp that might help to get list of all global variables in JavaScript project?

like image 615
Oleg Kandaurov Avatar asked Dec 22 '22 07:12

Oleg Kandaurov


1 Answers

You can loop through the window object for querying all globally defined data (variables and functions, including predefined ones):

for (var key in window) {
    console.log(key + "=" + window[key]);
}

For analysing the source code, use JSLint.

like image 186
Lekensteyn Avatar answered Dec 24 '22 02:12

Lekensteyn