By 05/02/2014 5 Comments

How to initialize an Array using the series of numbers in Javascript

Dynamically Initialization of an array at run time

  • In most cases we creating and initialize an array by hard coding
  • We can create and initialize an array dynamically at run time
  • For achieve that we use push() method


  • This function add new elements to an array

Following code describes the example of an array which create and initialize dynamically at run time. This array initialize from 1 to 1oo


var numbers = []; // declare an empty array

for(var i = 1; numbers.push(i++) < 100;); // loop through, call push function, the push function adds a new element every time into numbers array depends on condition inside for loop

document.write(numbers) // output here as numbers = [1,2,3 ... 100]


Posted in: JavaScript

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .