I have a simple, maybe a little dumb question regarding javascript associative arrays. Following is my problem:
var testArr = []; testArr["0000"] = "00000 - COST CENTER - BALANCE SHEET"; testArr["0017"] = "0017 - Test Team"; testArr["00033"] = "00033 - Test Team "; testArr["87210"] = "87210 - OFFICE OF THE PRESIDENT"; After these lines of code, testArr automatically sorts and shows like this:
testArr.87210 = "87210 - OFFICE OF THE PRESIDENT"; testArr.0000 = "00000 - COST CENTER - BALANCE SHEET"; testArr.0017 = "0017 - Test Team"; testArr.00033 = "00033 - Test Team "; In my case 0000 is supposed to be the first value and default. But due to this it is making 87210 as default. How can I overcome this?
EDIT : When I see the testArr in debugger window, I see something like the following. I am not able to upload image but please follow this. Thanks very much for your help. Much appreciated!!
testArr [87210] "87210 - OFFICE OF THE PRESIDENT"; [prototype] 0000 "00000 - COST CENTER - BALANCE SHEET"; 0017 "0017 - Test Team"; 00033 "00033 - Test Team "; I am not quite following why it is happening. The keys I am putting is "0000" not 0000. So in effect it should be a string right. Please explain