Linked Questions

4 votes
1 answer
9k views

How to get list of all variables defined in the current scope? [duplicate]

I wanted to be able to get a list of all variables in the current scope. I know it may not be possible (ex. 1, 2, 3 but it would really be helpful in simplifying a parsing algorithm for a Node/browser ...
Claudia's user avatar
  • 1,239
0 votes
1 answer
2k views

Print everything in my context [duplicate]

I am trying to do something funny with nodejs that requires me to run a single statement in javascipt that shows all the objects that are present in the current context. These objects might be just ...
Ashish Negi's user avatar
  • 5,263
0 votes
0 answers
24 views

Can I get A list of classes based on my current scope [duplicate]

For example, when I define two classes inside a function, can I somehow get a list of classes that were declared on the same level? function a(){ class Class1{ } class Class2{ } console....
Yurii Panasenko's user avatar
1 vote
0 answers
18 views

Is it possible to list all identifiers in JavaScript? [duplicate]

In Python, one can use dir() to list the names of all modules and variables that are accessible at any point in the code. I wonder whether the same is possible in JavaScript. I tried Object.keys(...
Fachu's user avatar
  • 11
328 votes
16 answers
622k views

View list of all JavaScript variables in Google Chrome Console

In Firebug, the DOM tab shows a list of all your public variables and objects. In Chrome's console you have to type the name of the public variable or object you want to explore. Is there a way - or ...
GRboss's user avatar
  • 6,389
32 votes
4 answers
24k views

String interpolation on variable

Say I have a variable str var str = "123" Now I could do console.log(`Hello ${str}`) and it will print Hello 123 Now I have another variable strnew var strnew = 'Hello ${str}' Note (based on ...
Faiz Mohamed Haneef's user avatar
15 votes
5 answers
2k views

Is it possible to get the local variable and parameter values with window.onerror

I have a simple javascript error logging mechanism in place and it looks somewhhat like this: window.onerror = function (ErrorMsg, Url, LineNumber, Col, Error) { // ajax these to the server, ...
frenchie's user avatar
  • 52.9k
5 votes
3 answers
29k views

Print all variables?

I want to do a function that can be used a lot in debugging that print all variables with their values. It would alert: x=3 y=2 The function would be like that : Exemple : var text=''; for(var a=...
user1342369's user avatar
  • 1,041
8 votes
4 answers
7k views

How to get local variable by its name in JS?

Working example with global var: var example_var = 'global var example'; var x = function(){ var var_name = 'example_var'; alert('Global var value is: ' + window[var_name]); } How can I do ...
klesh's user avatar
  • 85
10 votes
5 answers
2k views

get all values of the closure in node.js or V8

For example, if we assume the following code: var f = function() { return 'hello world' }; var x = 10; var y = 314; var g = function() { var buf = [], xx = x; while (xx--) buf.append(...
Aaron Yodaiken's user avatar
3 votes
2 answers
571 views

Any way to define ALL variables within function as property of this?

I know this may sound a little absurd, but I'm looking for a way to define every variable within a function as a property of this. I'm looking for any hack, any way possible to be able to have some ...
ThomasReggi's user avatar
  • 58.2k
0 votes
8 answers
2k views

Variable name within a loop

I suspect I am making a mistake in a basic JavaScript syntax. var my_array = new Array(10); for (var count=0; count<my_array.length; count++) { var my_array+count = "This is a variable number "+...
Dimitri Vorontzov's user avatar
3 votes
4 answers
1k views

C: Get all variables defined in current scope

This question has been asked before for other languages: Python, PHP and JavaScript. I would like to know if it is possible to do this in C. I am trying to get a snapshot of all the variables in my ...
JcMaco's user avatar
  • 1,278
4 votes
3 answers
3k views

Parsing JavaScript code in Java to retrieve variables' names

I have a Java String that contains javascript code, and i need to extract all the javascript vars' names. So, for the following javasctipt: var x; var a,b,c,d; var y = "wow"; var z = y + 'x'; I ...
poitroae's user avatar
  • 21.3k
5 votes
2 answers
4k views

Is there a way in JavaScript to get a list of all the local variables currently defined?

Say I have a function: function() { var a = 12; var b = 15; var c = list_of_all_local_variables } Is there a way in JavaScript to get a list of all the variables in the current scope, so ...
superluminary's user avatar

15 30 50 per page