Arrays: Arrays are use for store multiple data, data types and values in one variable.
Syntex: There are two ways to implementing arrays
Way 1:
var arrayName = new Array("array1","array2",..."array n");
Way 2:
var arrayName = ["array1","array2",..."array n"];
We can implied arrays by using [] Big braces or in other meaning [] braces indicate to arrays.
As example if i want to store data with name of 30 students than i use make new var for 30 times but by using of array we can store 30 names in one var name, let see an example:
var studentName = ["ankit", "jane", "janne", "jack","mac" ,"jhon"];
console.log(studentName);
In above example we create an array with var studentName and store all students names in it and than display array on console screen by using console.log command we can also use an alert command.
One more example : Store multi data types into array.
var myArray = ["Hello", 1, 2, true]; //here we store one string two integers and one boolean data type
console.log(myArray);
var myArray = ["Hello", 1, 2, true];
myArray[0] = "Hi there!"; //change the value of index 0.
console.log(myArray); //display Hi there! 1 2 true
myArray = ["rohan","nimit"];
myArray.push("ankit"); //Add an new array on last number of array list.
console.log(myArray); // rohan nimit ankit
myArray = [1,2,3,4,5];
myArray.pop(); //remove last one item of array list.
console.log(myArray); // 1 2 3 4
myArray = [2,3,4,5];
myArray.unshift(1); //add one item in starting in array list.
console.log(myArray); // 1 2 3 4 5
myArray = [1,2,3,4,5];
myArray.shift(); //remove first item from array list.
console.log(myArray); // 1 2 3 4 5
myArray = [1,2,3]; // array list 1
myArray1= ["Hello people", 10, 20, false], // array list 2
myArray2= ["Hello public", 30, 50, true,false]; // array list 3
var myArray = myArray.concat(myArray1).concat(myArray2); // join all array list in array list 1
myArray = [1,2,3]; // array list 1
myArray1= ["Hello people", 10, 20, false], // array list 2
myArray2= ["Hello public", 30, 50, true,false]; // array list 3
var myArray = myArray.concat(myArray1).concat(myArray2);
var joined = myArray.join("!--");
console.log(joined);
myArray = [1,2,3];
myArray.reverse();
console.log(myArray); // 3 2 1
myArray = ["d","e","g","b","a","f","h","c"];
myArray.sort();
console.log(myArray); // a b c d e f g h