-
each
Theeach
method iterates over the elements of its calling object and takes a block as an argument. During each iteration, the current element is passed as an argument to the block which is in turn bound to the block parameter. The return value from the block is ignored byeach
. When all the iterations are complete, the original calling array is returned byeach
. -
map
Themap
method iterates over the elements of its calling object and takes a block as an argument. During each iteration, the current element is passed as an argument to the block which is in turn bound to the block parameter. The return value from the block is appended to a new array. When all the iterations are complete, the new array object is returned bymap
. -
select
Theselect
method iterates over the elements of its calling object and takes a block as an argument. During each iteration, the current element is passed as an argument to the block which is in turn bound to the block parameter. Only the elements of the calling array for which the block returns a truthy value are appended to a new array. When all the iterations are complete, the new array object is returned byselect
.
last updated: