isArray
Array.isArray(mixed value)
=> {bool} test
#ES5pop
.pop()
=> {mixed} removes & returns last array element; if array is empty, returns undefined
#mutator
#safepush
.push(mixed value1, ... )
=> {num} new .length after adding values to end of array
#mutator
#safereverse
.reverse()
=> {arr-ref} reverses order of array, then returns a reference to itself
#mutator
#safeshift
.shift() => removes & returns first array element; or returns undefined if array is empty #mutator #safe
sort
.sort(func compare=unicode-point-values)
=> {arr-ref} sorts array, then returns reference to itself
#mutator
#safecompare
unshift
.unshift(mixed value1, ... )
=> {num} new .length after adding values to front of array
#mutator
#safeconcat
.concat(mixed value1, ...)
=> {arr} new array from primary + value1 + ...
#accessor
#safe
#shallow-copy - meaning reference types have their references copied, so both old and new arrays point to same referencevalue
- single values or array becomes the same dimension:
[1, 2].concat([3, 4], 5, [[6]]) => [1, 2, 3, 4, 5, [6]]
join
.join(str glue=',')
=> {str} array glued together into string
#accessor
#safeglue
- if not string, converted into one
slice
.slice(num start=0, num end=length) => #accessor #safe #shallow-copy
start/end
- if < 0, s/e=length+s/e
toString
.toString()
=> {str} array in string form; identical to .join()
#accessor
#safe - but ES5 uses .join() instead of .toString()indexOf
.indexOf(mixed searchValue, num start=0)
=> {num} first index w/ matching value, else -1
#accessor
#ES5start
lastIndexOf
.lastIndexOf(mixed searchValue, num start=length)
=> {num} last index w/ matching value, else -1
#accessor
#ES5start
forEach
.forEach(func iter, obj this=default-this)
=> {undefined}
#iterator
#ES5
# note - you can't break a .forEach loop, so use .some(return true) or .every(return false) if breaking is needed.iter
- args: value, index, array
every
.every(func iter, obj this=default-this)
=> {bool} iterates each element until false is returned, causing .every to return false, else returns true.
#iterator
#ES5iter
- args: value, index, array
some
.some(func iter, obj this=default-this)
=> {bool} iterates each element until true is returned, causing .some to return true, else returns false.
#iterator
#ES5iter
- args: value, index, array
filter
. filter(func iter, obj this=default-this)
=> {arr} creates a new array containing the elements who's iteration returned true
#iterator
#ES5iter
- args: value, index, array
map
.map(func iter, obj this=default-this)
=> {arr} creates a new array containing the *values* returned from each iteration
#iteration
#ES5
#note - iteration called on element when value !== undefinediter
- args: value, index, array
reduce
.reduce(func iter, mixed initial-value)
=> {mixed} each iteration receives the value returned from the previous iteration, until the loop ends and the last returned value is what .reduce returns.
#iterator
#ES5iter
- args: prevValue, arrValue, index, arr
initial-value !! READ CAREFULLY !!
reduceRight
.reduceRight(func iter, mixed initial-value)
=> {mixed} same as .reduce but loops from last to first
#iterator
#ES5