Get variable names with JavaScript

前端 未结 7 961
傲寒
傲寒 2021-02-08 18:47

I want to create a log function where I can insert variable names like this:

var a = \'123\',
    b = \'abc\';

log([a, b]);

And the result sho

7条回答
  •  说谎
    说谎 (楼主)
    2021-02-08 19:27

    test this.

    var variableA="valor01"; 
    var variableB="valor02"; var NamevariableA=eval('("variableA")');
    var NamevariableB=eval('("variableB")');
    console.log(NamevariableA,NamevariableB);

    atte. Manuel Retamozo Arrué

提交回复
热议问题