HTML and CSS Reference
In-Depth Information
JavaScript Element
Description
Array
An array created using one of the following object constructors:
newƒArray()
newƒArray( size )
newƒArray( e1 , ƒe2 ,ƒ… ƒen )
where size is the number of elements in the array and e1 through en
are individual array elements. If no parameter value is provided, the array
automatically grows as more elements are added.
Properties
index
For an array created by a regular expression match, the zero-based index of the
match in the string
input
The original string against which the regular expression was matched
length
The next empty index at the end of the array
prototype
A mechanism to add properties to an array object
Methods
concat( array )
Combines two arrays and stores the result in a third array named array
every( predicate )
Tests whether the condition expressed in predicate holds for all elements in the
array (true) or one counter-example exists (false)
filter( predicate )
Invokes the predicate function, creating a new array populated with the elements
of the original array that return a value of true from the function
forEach( func )
Invokes the func function for each element within an array
i ndexOf( value [ , start ])
Searches an array, returning the index number of the first element equal to value ,
starting from the optional start index
join( string )
Stores each element in a text string named string
lastIndexOf( value [ , start ])
Searches backwards through an array, returning the index number of the first ele-
ment equal to value , starting from the optional start index
map( func )
Creates a new array by passing the original array elements to the func function,
which returns elements based on a specified condition or expression
pop( )
“Pops” the last element of the array and reduces the length of the array by 1
push( arg1 , arg2 , ... )
“Pushes” the elements in the list to the end of the array and returns the new length
reduce( func )
Reduces an array by passing the original array elements to the func function, keep-
ing only those elements which return a value of true
reduceRight( func )
Reduces an array from the last element by passing the original array elements to
the function, func , keeping only those elements which return a value of true
reverse( )
Reverses the order of the elements in the array
shift( )
Removes the first element from an array, returns that element, and shifts all other
elements down one index
slice( array, begin,end )
Extracts a portion of the array, starting at the index number begin and ending at
the index number end ; the elements are then stored in array
some( predicate )
Tests whether the condition expressed in predicate holds for any elements in the
array (true); otherwise the value is false
sort( function )
Sorts the array based on the function named function ; if function is omitted, the sort
applies dictionary order to the array
splice( start,howMany,
[, item1 [, item2 [,…]]] )
Removes howMany elements from the array, beginning at index start and replaces
the removed elements with the itemN arguments (if passed); returns an array of the
deleted elements
toLocaleString()
Returns a localized string representation of the array
toString( )
Returns a string of the comma-separated values of the array
unshift([Item1 [,item2[,…]]])
Inserts the items to the front of an array and returns the new length of the array
 
Search WWH ::




Custom Search