w3resource
JavaScript Tutorial

Javascript Array Objects - Properties and Methods

Description

An Array is used to store a number of values (called as elements) in order with a single variable.

Can be created using javascript array object constructor.

new Array(size)

new Array(element0, element1, ..., elementN)

Parameters

size: The length of the array. If the value specified is not a number, an array of length 1 is created, with the first element having the specified value. The maximum length allowed for an array is 4,294,967,295.

element0,element1,...., elementN: A list of values for the array's elements

Example

w3r = new array ("php","html","css"); creates an array.
w3r[0] refers to php,
w3r[1] refers to html and
w3r[2] refers to css.

Javascript Array Objects Property

Name Description Version
constructor Specifies the function which creates an object's prototype. Implemented in JavaScript 1.2
index The position of a regular expression match within a string. Implemented in JavaScript 1.2
input Contains the original string against which the regular expression was matched. Implemented in JavaScript 1.2
length Returns the number of elements in an array Implemented in JavaScript 1.2
prototype Use to add new properties to all objects. Implemented in JavaScript 1.2

Javascript Array Objects Methods

Name Description Version
concat Use to join two or more arrays and returns a new array. Implemented in JavaScript 1.2
join Use to join all elements of an array into a string. Implemented in JavaScript 1.2
pop Use to remove the last element from an array. Implemented in JavaScript 1.2
push Use to add one or more elements at the end of an array. Implemented in JavaScript 1.2
reverse Use to reverse the order of the elements in an array. Implemented in JavaScript 1.2
shift Use to remove first element from an array. Implemented in JavaScript 1.2
slice Use to extract a section of an array. Implemented in JavaScript 1.2
splice Use to remove old elements and add new elements to an array. Implemented in JavaScript 1.2
sort Use to sort the elements of an array. Implemented in JavaScript 1.2
tosource Returns a string which represent the source code of the array. Implemented in JavaScript 1.2
tostring Returns a string represent the array and its elements. Implemented in JavaScript 1.2
unshift Use to add one or more elements to the beginning of an array and returns the new length of the array. Implemented in JavaScript 1.2
valueof Returns the primitive value of an array. Implemented in JavaScript 1.2

See also :

JavaScript Core objects, methods, properties.



New Content: Composer: Dependency manager for PHP, R Programming