json - How do I access an object property dynamically using a variable in JavaScript? -


i’m trying filter data json in javascript.

i define variable a. want property of whatever value a equal (not item.a). far i’ve been unable find way of doing it.

everything else working correctly because when changed specific entry (item.date example) works fine. cannot figure out correct syntax.

while(i< elements.length){     var a=elements[i].id;     if(elements[i].name == 'targetfeild'){       $(elements[i]).val($.map(result,function(item){var test = elements[i].id;return item.a;}));     }     i++; } 

try item[a], javascript objects can accessed way.


Comments

Popular posts from this blog

c# SetCompatibleTextRenderingDefault must be called before the first -

C#.NET Oracle.ManagedDataAccess ConfigSchema.xsd -

c++ - Fill runtime data at compile time with templates -