Home   Help Search Login Register  

Author Topic: Lookup array by primary key  (Read 2397 times)

0 Members and 1 Guest are viewing this topic.

Offline talkingtoaj

  • Members
  • *
Lookup array by primary key
« on: 16 May 2010, 05:09:40 »
Code: [Select]
_Array = [["a", 5, 4],["b", 2, 3],["c", 6, 1]]
So, if I'm treating the first elements of each array (a, b, c) as a primary key (perhaps refering to the name of a map marker), is there a way to do a lookup where instead of using a forEach loop, I can lookup the element that has primary key, say, "c", and retrieve the associated date (i.e. [6, 1])?

I guess I'm thinking of how we use hash-table lookups in other programming languages. Is it possible, or do we need to brute-force search the entire array using forEach?