Javascript examples for Array Operation:Array Index
Array split at index
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/* w w w . j a v a 2 s. c om*/ var arr = ['Number 1', 'name', 'Number 2', 'name'],res =""; for(var i=0,len=arr.length;i<len;i+=2){ res += arr[i] + ":" + arr[i+1] + ((i+2 != len) ? "," : ""); } console.log(res); } </script> </head> <body> </body> </html>