javascript associative array initialization error? -


<script> var tids = { 308: 1, 312: 1, 313: 1, 314: 1 }; </script> 

results in "missing } in xml expression arrow pointing first colon in js error console. isn't valid declaration?

first should fix <script> tag to

<script type="text/javascript"> 

next, if want use numeric indexes, try declare them string:

var tids = { '308': 1, '312': 1, '313': 1, '314': 1 }; 

please note, however, not able reference them in object notation (i.e. tids.308). use arrays instead of objects:


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -