Javascript: Working with Arrays (One Dimensional)

Working with arrays in Javascript is very simple. Specify the array elements in comma separated format in square formats.

var colors = ["blue", "red", "white", "green"];

The index of the first element of the array starts with 0. So to access the first element of the array

colors[0]
"blue"

You can find the length of an array using length

colors.length
4

Check how to work with 2 Dimensional arrays.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s