How to alert variable name, not a value

Posted by Randy Gurment on Stack Overflow See other posts from Stack Overflow or by Randy Gurment
Published on 2010-04-17T19:41:10Z Indexed on 2010/04/17 19:43 UTC
Read the original article Hit count: 181

Filed under:

Hi,

How to alert variable name, not a value of variable?

var color = 'red';

alert(color); // Will alert 'red'
alert(/* magic */); // Will alert 'color'

© Stack Overflow or respective owner

Related posts about JavaScript