Initializing Array in JavaScript

There are many ways we can initialize the Array in the JavaScript. JavaScript is a loosely types language. This means you need not worry about data type while storing them in Array. It can store any data type in a single array. Also you don’t need to provide the size of Array at the time of creation of Array. JavaScript will automatically adjust size of array according to the requirement. You can create Array by following declaration.
var array = [];

Another way of creating Array in JavaScript is
var secondArray = new Array(5);
This will create an Array of length 5.

Initializing an Array
You can initialize Array with pre defined data.
var dataArray = ['Tech', 'Pitcher', 'And', 'You'];

Related Post

Converting Array to List
Differences between Vector and ArrayList
jQuery – A lightweight JavaScript Library
String Number conversion in JavaScript
Sun turns JavaScript into Java. Google turns Java into JavaScript

Comments

One Response to “Initializing Array in JavaScript”

  1. Tim on September 29th, 2008 11:16 am

    It is simple and descriptive. Keep it up.

Leave a Reply




Technology