Hi guys,
If i have an associative array like this for example:
var arr:Array = new Array();
arr.push({name:"John", last:"Doe"});
arr.push({name:"Jane", lase:"Doe"});
How can i get array index of elements whose name property is “John” for example without looping through every array element and checking like this:
for(var i:uint=0; i<arr.length; i++)
{
if (arr*["name"] == "John")
{
//do smth
}
}
I tried using indexOf which works with normal arrays but i guess not with associative array, i tried the following:
trace(arr.indexOf({name:"John"}));
But that didn’t work. Anyone has better idea? Can even indexOf() be used this way with associative arrays?
Thanks in advance,
Best regards