Hi,
I am trying to execute a condition to see if a particular value is an element of an array. say something like
if(a== elementOf(idArray)) {
trace(“yes”);
}
Is there a way to do the above or the only way is to code it to search through the array. Kindly pour in some ideas…
Thanks,
jay
I don’t think there is a built in search function, so you’ll have to code one yourself. Here’s a simple one you can use:
Array.prototype.inArray = function(needle){
for(var i=0;i<this.length;i++) if(this* == needle) return true;
return false;
}
test = new Array("kirupa","kirupaforum","macromedia","flash");
trace(test.inArray("kirup"))
trace(test.inArray("kirupa"))