Javascript examples for Array Operation:Associative Array
Use associative array to store objects
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script type="text/javascript"> var id=2;/* ww w .jav a2 s . co m*/ var myArray={} myArray["sede_"+ id] = "ciao"; myArray["sede_"+ (++id)] = "espresso"; var len = 0; for (var o in myArray) { if (myArray.hasOwnProperty(o)) len++; } myArray.length=len; console.log(myArray.length) </script> </body> </html>