javascript - Can I access a variable's name as a string after passing it as an argument to another function? -


perhaps dim question i'm trying design i'm using javascript / jquery change layout of website , i'd see values of both variable name , it's current value in div.

i doing $test.append('example string' + examplevar) lot thought make function called test().

so far have:

function test (test) {     $test = $('.test');     $test.append(test+"<br>"); } 

and pass variable name argument can't find way of making display name string. know making object access key , value doesn't seem work here?

bit of long-winded way it, here's example using object:

function tester(options) {   var keys = object.keys(options);   console.log(keys[0] + ': ' + options[keys[0]]); // test: value }  tester({ test: 'my value' }); 

demo


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -