Javascript examples for Object:Reflection
Get variable name using "reflection"
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*ww w . j av a 2 s .c o m*/ //This is variable you want to get the name var prop; var obj = {prop}; for(var propName in obj){ console.log(propName); break; } } </script> </head> <body> </body> </html>