You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varescope=require("escope"),esprima=require("esprima");varsrc=require("fs").readFileSync("source.js");varast=esprima.parse(src),scopes=escope.analyze(ast).scopes;// dump names of variables in the global scopeconsole.dir(scopes[0].variables.map(function(variable){returnvariable.name}));
I get the following outpout: ["a", "x"]
Interestingly, if I change x = 42 to x() or simply x, it does not appear in the output.
Am I using escope incorrectly or why is x in the global scope?
The text was updated successfully, but these errors were encountered:
Consider the following source:
When I run escope via this script:
I get the following outpout:
["a", "x"]
Interestingly, if I change
x = 42
tox()
or simplyx
, it does not appear in the output.Am I using escope incorrectly or why is
x
in the global scope?The text was updated successfully, but these errors were encountered: