View Single Post
Old 10-09-2012, 01:06 AM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,200
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
I also have to ask: Suppose your incoming array looks like this:
Code:
[  "adamson = 123", "jones = 775", "adams = 999" ]
If you ask for "adams", you are going to find "admason" first. Is that really what you want?

Seems to me like this kind of array is a mistake. I think you would want an object with multiple properties, thus:
Code:
var userinfo = {
    "adamson" : 123,
    "jones" : 775,
    "adams" : 999
    };
And now you could just do
Code:
    var value = userinfo["adams"];
Much more efficient and you won't get "false positive" matches.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote