Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124


Array in JavaScript is used to store multiple values in a single variable. It is just like objects which has methods to perform traversal and mutation operations. Neither the length of a JavaScript array nor the types of its elements are fixed.
Array literal is the easiest way to create an array in JavaScript.
var color= ['red', 'blue', 'green','yellow'];
Another way is to create an array in JavaScript using Keyword new.
var color= new Array('red', 'blue', 'green','yellow');
Javascript array elements can be removed by using array length property. An element greater than or equal to the given length will be removed.
var array = [1, 2, 3, 4, 5, 6]; array.length = 2; console.log( array ); // [1, 2]
The pop method will delete the last element of an array.
var array = [1, 2, 3, 4, 5, 6]; array.pop() console.log( array);
This method is used to remove the first element of the array and reducing the size of original array by 1.
var array = [1, 2, 3, 4, 5, 6]; array.shift() console.log(array);
This method is used to modify the contents of an array by removing the existing elements and/or by adding new elements. To remove elements by splice() method you can specify the elements in different ways.
var array = [1, 2, 3, 4, 5, 6]; array.splice(2,2) console.log(array);
Unlike the splice method, filter creates a new array. filter() does not mutate the array on which it is called, but returns a new array.
var array = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present']; var result = array .filter(word => word.length > 6); alert(result);