Javascript examples for Array Operation:Array Index
Array for loop, assign value and access value
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script> var numbers = [];/*from w w w .j av a 2s. c om*/ var sum = 0; for (var i = 0; i <= 100; i = i + 3) { numbers[(i-3)/3] = i; } for (var index = 0; index < numbers.length; index++) { document.write("<br/>" + numbers[index]); sum = sum + numbers[index]; } document.write("<br/>sum = " + sum); </script> </body> </html>