Array Methods Quick Reference

from JavaScript with Native Objects, Frontend Engineering, Volume 3, ©2011, Martin Rinehart

Original0 Returns X-Browser Issue
concat( item(s)1 ) result reference
indexOf( value2 ) index3 partial IE8, not IE7
join( separator ) result reference4
pop() Last element is deleted.5 last element5
push( item(s)1,6 ) Items are pushed. new length
reverse() Elements are reversed. result reference
shift() First element is deleted.5 first element5
slice( start[, end]7 ) start through [or to, but not including] end8
sort( comp_func ) ASCII (or comp_func) sorted result reference
splice( index, # to del[, item(s) to insert]1, 10 ) Spliced array. deleted element(s)
toString() a0.toString() + ',' + a1.toString() + ...
unshift( item(s)1,6 ) item(s).concat( original ) new length
valueOf() [a0.valueOf(),a1.valueOf(),...]

Browsers performing exactly as documented, November 11, 2011, are Chrome, Firefox and Opera.

0 Blank if original is not changed.
1 Zero or more primitives or object references (any type). Elements of concatenated arrays are individually concatenated (recursively).
2 Value may be a primitive or an object reference (any type).
3 -1 if not found. Comparison is strict.
4 Result is concatenation: a0.toString() + separator + a1.toString() + ...
5 Pop/shift of empty array leaves array empty, returns undefined.
6 Unlike concatenation, pushed or unshifted reference to an 'instanceof Array' is still an 'instanceof Array' in the result (returned value or revised original).
7 If end <= start, no elements are sliced. If end >= length, all remaining elements are sliced.
8 List item is included if end is not specified. If specified, end index is excluded.
9 'comp_func' compares two items. Returns positive if first is greater; zero if equal; otherwise negative; Examples:

var numeric_sort = function ( a, b ) { return a - b; }
var case_insensitive_sort = function ( a, b ) {
    if ( a.toUpperCase() > b.toUpperCase() ) { return 1; }
    if ( a.toUpperCase() === b.toUpperCase() ) { return 0; }
    return -1;
}
10 No args, one arg: returns empty array. Number deleted is lesser of '# to del' or all remaining elements. Deletions begin at index. a.splice(n) leaves a.length === n.
11No args: returns undefined.