showing results for - "variable name as a string in javascript function"
Lucas
15 Nov 2020
1const myFirstName = 'John'
2Object.keys({myFirstName})[0]
3
4// returns "myFirstName"
Beatrice
12 Sep 2019
1//Get variable name as string
2function getVariableName(v) {
3    for (var key in window) {
4        if (window[key] === v)
5            return key;
6    }
7}
8
9//testing
10var someValue = "something not important right now";
11console.log(getVariableName(someValue)); //>> prints "someValue"
12//also works in functions
13function print(a) {
14  console.log(getVariableName(a)); //>> prints "someValue" because of line 16
15  //you'd think it would print "a" but it doesnt
16}
17print(someValue);//>> look at line 14
Daniel
30 Jul 2017
1var a = [1, 3, 4, 3]
2var b = [1, 5, 6, 7]
3var c = [3, 4, 8, 9]
4
5function arraySum(x, varName) {
6    var sum = 0
7    for (let i = 0; i < x.length; i++) {
8        sum += x[i]
9    }
10    console.log("sum of " + varName + " is " + sum)
11}
12
13arraySum(a, "a");
queries leading to this page
turn string into variable name javascriptget variable with name jsaccess variable name in javascriptjavascript how to get the variable namereturn variable that with name of string jsjavascript get variable name stringjs variable in function namehow to use 25 in a variable name javascriptvariable function name in javascripthow can we use variable name as text in jsget string of variable name javascriptget name of var jsconvert string to variable name jshow to turn the name of a variable into a string javascriptjs return variable namehow to return variable name in javascriptreturn a variable name as a string javascriptvariable name is a string value in jsget the var name jswhy can i name a variable name in javascriptjavascript change variables name to stringjavascript function name to stringjavascript get variable from string namejs variable namevariable with name in javascriptjavascript 24 get 5b 22name 22 5dnode js make variable with string as nameshow name of variable javascriptdefine a variable name with a string nodejsconvert string value to variable name javascriptreturn 21 21 varname in jsjavascript get var from namehow to write variable name in javascripthow to get variable name string jshow to make variable name as string in jsvariable name to string jsget variable namename variable in javascriptvariable name in jsuse string into variable name jsvariable name to string javascritpget variable using its name as string javascriptuse msg value or variable as key javascripthow to get the variable name inside the function javascriptget variable name as string jsget the name of variable javascript as stringhave a string call a variable name 2c jshow to make a varianle name from a string in jsget varible name string jshow to access the name of a variable javascripjavascript get name of variable in function as stringhow to get a variable name in javascriptconvert string to variable name in javascripthow to get variable name in jshow to attach variable name to string in javascriptcall var name by stringjavascript get string of variable namejs how to know variable nameget name of variable jsjavascript function param variable name as in stringchange string to variable name javascripthow to make nodejs see variable name as a stringjs convert string to variable namejavascript access variable from string namejavascript convert name to stringjavascript how o make name of string varget string representation of variable name javascriptuse variable name as string javascript 24 7bvariable name 7d 26 name in javascriptconvert variable name to string in javascriptjavascript get variable namejavascript set variable name from stringcreate variable name from string jsget string from variable name jsget name from type javascriptjavascript string to variable namejs name of variablehow to turn string into variable name jshow to get the string name of a variable in javascriptusing string as a variable name in javascriptjavascript string as variable namevariable name 24 javascriptjavascript get variable name as stringhow to use variable name as string javascriptjs string in variable namejs how to know a variable namejs var name 3d 7b 7djs how to access the name of the variablejavascript get variable name form stringjavascript use variable name as stringhow to convert a string to normal variable name in javascriptjavascript variable in a name stringset variable data from string var name jsjs string as variable namejs variable name of variablejs variable name with variablehow to turn variable name into string javascriptget the name of variable jsjavascript 2c compare variable namesuse string as a variable name javascriptjs how to get variable name as stringjs print variable name as stringget name of variable javascriptpass variable name as string and get that variable javascriptnode js variable name to stringcreate a variable name from a string javascriptjs get variable by nameprint variable name and avalue javascriptvariable name in javascriptjavascript nameof variablejs use variable name as stringjavascript pass variable name as stringget var name jsjavascript variable variable namejs name of the variablejavascript variable name 24js output variable namechange variable name to string javascriptuse a string to name a variable jsjavascript create function with variable namejavascript name of variable as stringget the name of a string variable javascriptjs get variable namejavascript variable name with 24get value of variable when variable name in string javascriptjavascript use a string as a variable namestring to variable name in jsjavascript get element by variable nameconvert the string of a variable name into a variable value jsjavascript get variable name from string valueturn variable name into string javascriptvariable name with 24 javascriptthe name of the variable as string javascripthow to get variable name as string in jshow to make javascript see variable name as a stringhow to convert a string to a variable name in javascriptjs get string of variable namejavascript change string to variable namevariable name as a string in javascript functionreturn variable name as string jsstring to var name in jsnodejs print variable name and valuejavascript get variable value by nameuse string as variable name jsjavascript strig name to var namejavascript get the variable namehow to get variable name as string javascriptjs variable name stringget the name of a variable javascriptget variable name as a string jsjavascript variable name to stringjavascript variable name from stringjs how to select variable for same name stringhow to use string as variable name in javascripthow to print the variable name in javascriptsome way to print variables name in jsjavascript convert string to variable namenode js string to variable nameget variable name from string javascriptjavascript set variable by string namejavascript set string as variable namejavascript variable name from valuedefine a variable name with a string javascriptjs create variable name from stringjavascript print variable namehow to create function with variable name in jsjs create varname from stringhow to get store variable name in jsjs name variable functionstring to variable name javascriptname of a variable as a string jsget name of variable from its value javascriptcan variable name be a string in jsvar name 3d function 28 29 in jsreturn javascript variable namejavascript get value for variable namehow to get variable name as string in javascriptget variable name from variable javascriptvariable name as function name in jsget variable name in javascripthow to convert string to variable name in javascriptrepresebt variable name as string javascriptvariable with string name javascriothow to display variable name in javascriptuse variable name as string jsturn variable name into string jsjavascript convert a string to a variable namejs variable as different namehow to make a string a variable name javascripthow to make javascript variable namejavascript get variable name to stringget variable name as string javascriptusing string as variable name in js 7b 24 7djs make function name string 24 javascript variable nameget variable by name javascriptvariable in name jsjs var name from stringjavascript stringify variable namejs get value of name of variablestring to var name javascriptget variable name as a string javascripthow to parameter to be name of variable javascripthow to convert variable name to string in jsget var name javascriptjs get name of variablesjavascript variable function namehow to have 26 in variable name jsjs use variable as function nameget name of variable as string javascriptjs string as function namehow to get variable name in javascriptjavascript get name of function variablejs how to use string variable as function namejs variable name from stringhow to include a variable name in a javascript stringjs variable name to stringjs variable name from variablejs set function name from string variablejavascript function to variable namejs get var name as stringjavascript get name of variable as stringjs string to variable nameget the variable name in jsuse string as variable name javascriptget js variable namehow to find variable name using string javascriptjavascript function name as stringvariable name to string javascriptconvert string into variable name javascripthow to get a variables name javascriptjavascript 2c get name of variable as stringjavascript create variable name from stringjavascript text variable function namejavascript convert variable name to stringjs access variable name using string referance 23 as variable name in jsstring to variable name jsvariable function name jsjavascript get variable name udrfjavascript get variable by name stringjavascript get variable name usedget variable name javascriptconvert a string to variable name javascriptjavascript name a variablewith stringjavascript variable name as stringget variable value javascripthow to get the variable name in javascriptjavascript access variable nameusing string as variable name in jsgive a varaible name as string in jsvar name in javascriptjs variable name as stringvariable name string javascriptjavascript know name of variablecan i use as variable name in javascriptjavascript name in variablevariable with 22name 22 in javascripthow to print the variable name along with it 27s value in javascriptvariable name as a string in javascripthow to store variable name as string javascript 2bvariablename jsreturn the name of the var as string javascriptjs get name of variablecan i use 24 as variable name in javascriptcreate a variable with string name javascriptjavascript name variable javascript var name 3d functionjavascript get the name of variablehow to print variable name in javascriptjavascript pass string as variable namehow to name a javascript variablevariable name as string javascriptjavascript ge variable namefind var name from string in jsjavascript get name of variablenode log variable nameis 24 var name jshow to use variable name of js in stringget string of variable name jshow to use variable function name in javascripthow to convert variable name to string in javascriptvar name inside a string jsget variable name jsget var name from string jsjs get string as var nameget variable name string javascripthow to get name of variable jsjavascript get a variable name as a stringusing string to name variable javascriptnodejs make a variable name a stringget variable by string name javasciptjavascript name of variableconvert variable name to string javscriptpass variable name as string in jsconvert variable name to string javascriptconvert string to variable name javascriptget variable name from function javascriptget variable name from the value javascripthow to make var name from string in jsjs get variable name in functionjavascript name in stringjavascript function with variable namejavascript get variable with string nameuse this to get variable name javascripthow to get the name of a variable in javascriptjavascript function name variablehow to get name of variable javascriptjs extract variable nameget js variable name from valuejs get variable name as stringconvert variable name to string jsget variable by name jsjavascript function param variable name as stringnode js variable name from stringjs call variable by stringjavascript turn variable name into stringvariable name from variable javascriptjs get varble namejs name variablejavascript use variable name from stringjs acces name of a variablevariable name as a string in javascript function