Sunday, 19 January 2020

Arrays in Javascript

Hello everyone today in this post I like to share with you about Arrays in Javascript.

Variables help us to store single value but array is a variable that stores multiple values.
An array is a special variable, which can hold more than one value at a time.
If you have a list of items (a list of car names, for example), storing the cars in single variables could look like this:
var car1 = "Saab";
var car2 = "Volvo";
var car3 = "BMW";
However, what if you want to loop through the cars and find a specific one? And what if you had not 3 cars, but 300?
The solution is an array!
An array can hold many values under a single name, and you can access the values by referring to an index number.
 it is described in w3schools.com about arrays
In JavaScript we use squarebraces to declare as array
 var arrayName = [value1, value2, ...];
We use index to point out a specific value in array.
The index starts from 0 and continue 1, 2, 3 and respectivly.

There are many methods to use in array.
here are some lists of arrays method.

No comments:

Post a Comment