radalin Posted October 12, 2006 Share Posted October 12, 2006 I have question about javascript and array system. I'm using javascript in my web site and I would like to enable a language selection on it. I'm using language options from php side. an associative array, containing values like $lang["Hello"] => "Hello", and this goes on. Is there a way to do this with javascript? I mean is there a such an assosiative array option in javascript (which I do not think it's possible.). I have intended to use a getLang function which takes an argument about lang and with switch statements it returns the right value. Well that's ok but it will take a lot of time if I have thousand cases. Any idea is welcome.Thanks... Quote Link to comment Share on other sites More sharing options...
fenway Posted October 12, 2006 Share Posted October 12, 2006 Yes, JS support associative arrays a.k.a. hashes:var myAA = {};myAA['key1'] = 'value1';Strictly speaking, you can mix arrays and hashes, but don't (read: don't use numbers as the keys). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.