javascript "associative" array access

Posted by cp on Stack Overflow See other posts from Stack Overflow or by cp
Published on 2010-03-26T15:27:39Z Indexed on 2010/03/26 15:33 UTC
Read the original article Hit count: 162

Filed under:
|
|

Hello I have a simple simulated aarray with two elements:

bowl["fruit"]="apple";
bowl["nuts"]="brazilian";

I can access the value with an event like this:

onclick="testButton00_('fruit')">with `testButton00_`

function testButton00_(key){
    var t = bowl[key];
    alert("testButton00_: value = "+t);
}

However whenever I try to access the aarray from within code with a key that is just a non-explicit string I get undefined. Do I have somehow have to pass the parameter with the escaped 'key'. Any ideas? tia.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about associative