Get all declared variables in Node.js?

Hello! I am looking for a way to access all vars in a node.js script (from inside a script).

I know there is “global” which can access variables when declared like:
foo = “123”;

I want to know a way to find all the variables declared even with “var”.
var foo = “123”;
example ^

Is there a way?