Please enable JavaScript.
Coggle requires JavaScript to display documents.
Array - Coggle Diagram
Array
Arrays
-
Methods pop/push, shift/unshift
-
-
-
-
-
Internals
The engine tries to store its elements in the contiguous memory area, one after another
if you need arbitrary keys, chances are high that you actually require a regular object {}
Performance
push/pop run fast, while shift/unshift
-
-
new Array()
-
then it creates an array without items, but with the given length.
-
Array methods
Add/remove items
arr.splice(start[, deleteCount, elem1, ..., elemN])
-
-
arr.slice([start], [end])
-
-
arr.concat(arg1, arg2...)
accepts any number, arrays, or values
-
-
-
-
Transform an array
-
sort(fn)
-
To use our own sorting order, we need to supply a function as the argumentof arr.sort().
-
-
reduce/reduceRight
The function is applied to all array elements one after another and “carries on” its result to the next call.
if there’s no initial, then reduce
takes the first element of the array as the initial value and starts the iteration from the 2nd element.
if don't have initial value and array is empty then reduce call without initial value gives an error.
arr.reduceRight does the same, but goes from right to left.
-
arr.fill(value, start, end)
-
arr.copyWithin(target, start, end)
copies its elements from position start till position end into itself, at position target (overwrites existing).
arr.length not change, if it overflowing it'll ignore
-
-
-
-
-