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' });
Comments
Post a Comment