Begin Web Programming with PHP & MySQL

Advertisements



JavaScript Array Object

The array object helps to store multiple values in a single variable.
Syntax:
var array = new Array(val1, val2, val3 …);

Properties of Array Object
Property Description
constructor It returns a reference to the array function that created the object.
prototype It is used to add new properties and methods to an array object.
length It returns the number of elements in an array.

Methods of Array Object
Method Description
concat() It joins two or more arrays and returns the resulting array.
join() It joins all the elements of an array into a string.
pop() It removes the last element from an array.
push() It adds one or more elements at the end of an array.
reverse() It reverses the order of the elements in an array.
shift() It removes the first element from an array.
slice() It is used to extract a portion of an array.
splice() It is used to remove some elements from an array and add new elements.
sort() It sorts the elements of an array.
some() It returns true if at least one element in this array satisfies the provided testing function.
toSource() It represents the source code of the object.
toString It returns a string representing the array and its elements.
unshift It adds one or more elements to the front of an array and returns the new length of the array.