This question already has answers here:
Access JavaScript property case-insensitively?
(19 answers)
"Variable" variables in JavaScript
(9 answers)
Closed 11 months ago.
I am trying to fetch value using below statement
var variable_2 = context.getVariable(variablefetch);
My requirement is to fetch this variable_1 irrespective of case.
For example if value of this variablefetch could be stored as
variablefetcH = typea
VAriablefetch = typea
VARIABLEFETCH = typea ....etc
So irrecpective of what i pass (in above case variablefetcH,VAriablefetch,VARIABLEFETCH) it shoule be able to fetch value tyea
Related
This question already has answers here:
"Variable" variables in JavaScript
(9 answers)
Closed 1 year ago.
let varone = "vartwo";
let vartwo = "answer";
And I would like to get "answer". But I cannot do the following:
console.log(vartwo);
How can I get "answer", but not by including "vartwo" in my code?
I think one way to resolve it, is by using javascript objects, as shown:
obj={
varone:"vartwo",
vartwo:"answer"
};
console.log(obj[varone]) //outputs "answer"
This question already has answers here:
Add a property to a JavaScript object using a variable as the name? [duplicate]
(14 answers)
Closed 4 years ago.
CODE:
let name = 'bam';
doc.name = req.body[x].value;
PROBLEM:
I want it to return doc.bam value but actually it get doc.name value while I set name='bam'.
For computed properties you should use []
var doc = {};
let name = 'bam';
doc[name] = "abc";
console.log(doc.bam);
This question already has answers here:
Why global variable 'name' changes to string? [duplicate]
(1 answer)
Using the variable "name" doesn't work with a JS object
(4 answers)
Closed 6 years ago.
can any one please explain why the value of name variable is "" . in java script declared variable always has value undefined?
This question already has answers here:
JavaScript Dynamic Variable Names [duplicate]
(6 answers)
Closed 6 years ago.
Is it possible to use button attribute as a variable name of an array in JavaScript? I tried to do it as follows but it returns syntax error.
var $(this).attr("value") = [];
Is there any way to do this?
var buttonValueAttribute = $(this).attr('value');
This question already has answers here:
Variable as the property name in a JavaScript object literal? [duplicate]
(3 answers)
Closed 8 years ago.
var diena = "example"
array.push({diena: sub_array});
I want to array key use variable and have key "example" not "diena". How I can do this ?
You'll need to construct the object beforehand.
var diena = "example";
var obj = {};
obj[diena] = sub_array;
array.push(obj);