This is an example function that can search for a key in a javascript array and return it...
function check(v)
{
var x = new Array();
x = { a: '1', b: '2', c: '3' };
for(var key in x)
{
if(x[key] == v)
console.log(key);
}
}
Test:
check(2); // b
function check(v)
{
var x = new Array();
x = { a: '1', b: '2', c: '3' };
for(var key in x)
{
if(x[key] == v)
console.log(key);
}
}
Test:
check(2); // b
Comments
Post a Comment