How to warn a variable name, not a value

How to warn a variable name, not a variable value?

var color = 'red'; alert(color); // Will alert 'red' alert(/* magic */); // Will alert 'color' 
+4
source share
2 answers

This is not possible in JavaScript, because arguments in this language are passed by value or by reference, not by name, so when a variable is passed to a function, its name is lost.

+5
source

In the Firebug console:

 >>> a=[] [] >>> a [] >>> b=a [] >>> a.push(3) 1 >>> b [3] >>> a [3] 

So, what variable name would you like to return to this array? a ? b ? Is something completely different?

+2
source

Source: https://habr.com/ru/post/1307233/


All Articles