Arrays Flashcards
toString()
returns a string with the toString method called on each element, separated by commas
concat(item1 [,item2, …])
returns a new array with the items added to it. works for single elements as well as other arrays
join(sep)
converts an array to a string, and delimits values with the sep param. if sep not specified, it will use empty string to delimit.
pop()
removes and returns the last value in the array
push(item1, [,item2 …])
appends items to the end of the array
shift()
removes and returns the first value in the array
unshift(item1 [,item 2, …])
inserts items at the start of the array
slice(start [, end])
returns a sub-array from index start to end. if end is not specified, the last index is the ‘end’
sort([cmpfn])
sorts the array using the given comparison function
splice(start, delcount, [, item1[, …]])
lets you modify an array by deleting a section and replacing it with more items
reverse()
reverses a given array