P
ROTOTYPE
I'm Not Only The Prototype, I'm Also A Member.
home
▪
stats
▪
search
▪
linkback
▪
about
▪
FAQ
| user: guest,
login
,
register
Array
:
Array.prototype.getArrayID_2D
author:
TunaFish
[+]
,
Submitted: 04.22.05 5a
// return the index in a 2D array Array.prototype.getArrayID_2D = function(value, objName) { var i = this.length; while(i--) { if(this[i][objName] == value) { return i; } }; }; // example foo_array = [ {fruit:"apple", color:"green"}, {fruit:"orange", price:0.76}, {fruit:"banana", color:"yellow"} ]; trace(foo_array.getArrayID_2D("banana", "fruit")); // -> 2 trace(foo_array.getArrayID_2D(0.76, "price")); // -> 1
usage
USAGE my_array.getArrayID_2D(value1 "value2":String ) : Array PARAMETERS value1 A value we are looking for value2 A string representing the name of the object RETURNS The index in the array
Add Comment
[+]
›opyleft 2001-2010. Layer51 is: Jaime Prado.
@