Skip to content

Instantly share code, notes, and snippets.

@rauschma
Last active April 11, 2023 21:31
Show Gist options
  • Save rauschma/f7b96b8b7274f2e2d8dab899803346c3 to your computer and use it in GitHub Desktop.
Save rauschma/f7b96b8b7274f2e2d8dab899803346c3 to your computer and use it in GitHub Desktop.

Revisions

  1. rauschma revised this gist May 30, 2021. 1 changed file with 1 addition and 319 deletions.
    320 changes: 1 addition & 319 deletions api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -1,319 +1 @@
    # `Array<T>`

    Legend:

    * ✏️ method changes `this`.
    * 🔒 method does not change `this`.

    `Array<T>.prototype.*`:

    * `concat(...items: Array<T[] | T>): T[]` 🔒 <sup>ES3</sup>

    Returns a new array that is the concatenation of `this` and all `items`. Non-array parameters are treated as if they were arrays with single elements.

    ```repl
    > ['a'].concat('b', ['c', 'd'])
    [ 'a', 'b', 'c', 'd' ]
    ```

    * `copyWithin(target: number, start: number, end=this.length): this` ✏️ <sup>ES6</sup>

    Copies the elements whose indices range from `start` to (excl.) `end` to indices starting with `target`. Overlapping is handled correctly.

    ```repl
    > ['a', 'b', 'c', 'd'].copyWithin(0, 2, 4)
    [ 'c', 'd', 'c', 'd' ]
    ```

    * `entries(): Iterable<[number, T]>` 🔒 <sup>ES6</sup>

    Returns an iterable over [index, element] pairs.

    ```repl
    > Array.from(['a', 'b'].entries())
    [ [ 0, 'a' ], [ 1, 'b' ] ]
    ```

    * `every(callback: (value: T, index: number, array: Array<T>) => boolean, thisArg?: any): boolean` 🔒 <sup>ES5</sup>

    Returns `true` if `callback` returns `true` for every element. Stops as soon as it receives `false`. Math: ∀

    ```repl
    > [1, 2, 3].every(x => x > 0)
    true
    > [1, -2, 3].every(x => x > 0)
    false
    ```

    * `fill(value: T, start=0, end=this.length): this` ✏️ <sup>ES6</sup>

    Assigns `value` to every index.

    ```repl
    > [0, 1, 2].fill('a')
    [ 'a', 'a', 'a' ]
    ```

    * `filter(callback: (value: T, index: number, array: Array<T>) => any, thisArg?: any): T[]` 🔒 <sup>ES5</sup>

    Returns an array with only those elements for which `callback` returns `true`.

    ```repl
    > [1, -2, 3].filter(x => x > 0)
    [ 1, 3 ]
    ```

    * `find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined` 🔒 <sup>ES6</sup>

    The result is the first element for which `predicate` returns `true`. If it never does, the result is `undefined`.

    ```repl
    > [1, -2, 3].find(x => x < 0)
    -2
    > [1, 2, 3].find(x => x < 0)
    undefined
    ```

    * `findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number` 🔒 <sup>ES6</sup>

    The result is the index of the first element for which `predicate` returns `true`. If it never does, the result is `-1`.

    ```repl
    > [1, -2, 3].findIndex(x => x < 0)
    1
    > [1, 2, 3].findIndex(x => x < 0)
    -1
    ```

    * `forEach(callback: (value: T, index: number, array: Array<T>) => void, thisArg?: any): void` 🔒 <sup>ES5</sup>

    Calls `callback` for each element.

    ```js
    ['a', 'b'].forEach((x, i) => console.log(x, i))
    // 'a' 0
    // 'b' 1
    ```

    * `includes(searchElement: T, fromIndex=0): boolean` 🔒 <sup>ES2016</sup>

    Returns `true` if `searchElement` SameValueZero-equal to an element and `false`, otherwise. SameValueZero-equal means: strictly equal, but `NaN` is also equal to itself.

    ```repl
    > [0, 1, 2].includes(1)
    true
    > [0, 1, 2].includes(5)
    false
    ```

    * `indexOf(searchElement: T, fromIndex=0): number` 🔒 <sup>ES5</sup>

    Returns the index of the first element that is strictly equal to `searchElement`. Returns `-1` if there is no such element. Starts searching at index `fromIndex`, visiting subsequent indices next.

    ```repl
    > ['a', 'b', 'a'].indexOf('a')
    0
    > ['a', 'b', 'a'].indexOf('a', 1)
    2
    > ['a', 'b', 'a'].indexOf('c')
    -1
    ```

    * `join(separator = ','): string` 🔒 <sup>ES1</sup>

    Creates a string by concatenating string representations of all elements, separating by `separator`.

    ```repl
    > ['a', 'b', 'c'].join()
    'a,b,c'
    > ['a', 'b', 'c'].join('##')
    'a##b##c'
    ```

    * `keys(): Iterable<number>` 🔒 <sup>ES6</sup>

    Returns an iterable over the keys of the array.

    ```repl
    > [...['a', 'b'].keys()]
    [ 0, 1 ]
    ```

    * `lastIndexOf(searchElement: T, fromIndex=this.length-1): number` 🔒 <sup>ES5</sup>

    Returns the index of the last element that is strictly equal to `searchElement`. Returns `-1` if there is no such element. Starts searching at index `fromIndex`, visiting preceding indices next.

    ```repl
    > ['a', 'b', 'a'].lastIndexOf('a')
    2
    > ['a', 'b', 'a'].lastIndexOf('a', 1)
    0
    > ['a', 'b', 'a'].lastIndexOf('c')
    -1
    ```

    * `map<U>(callback: (value: T, index: number, array: ReadonlyArray<T>) => U, thisArg?: any): U[]` 🔒 <sup>ES5</sup>

    Returns a new array, in which every element is the result of `callback` being applied to the corresponding element of `this`.

    ```repl
    > [1, 2, 3].map(x => x * 2)
    [ 2, 4, 6 ]
    > ['a', 'b', 'c'].map((x, i) => i)
    [ 0, 1, 2 ]
    ```

    * `pop(): T | undefined` ✏️ <sup>ES3</sup>

    Removes and returns the last element of the array. That is, it treats the end of the array as a stack.

    ```repl
    > const arr = ['a', 'b', 'c'];
    > arr.pop()
    'c'
    > arr
    [ 'a', 'b' ]
    ```

    * `push(...items: T[]): number` ✏️ <sup>ES3</sup>

    Adds adds zero or more `items` to the end of the array. That is, it treats the end of the array as a stack. The return value is the length of `this` after the change.

    ```repl
    > const arr = ['a', 'b'];
    > arr.push('c', 'd')
    4
    > arr
    [ 'a', 'b', 'c', 'd' ]
    ```

    * `reduce<U>(callback: (state: U, element: T, index: number, array: T[]) => U, firstState?: U): U` 🔒 <sup>ES5</sup>

    The `callback` computes the next state, given the current state and an `element` of the array. `.reduce()` feeds it the array elements, starting at index 0, going forward. If no `firstState` is provided, the array element at index 0 is used, instead. The last state is the result of `.reduce()`.

    ```repl
    > [1, 2, 3].reduce((state, x) => state + String(x), '')
    '123'
    > [1, 2, 3].reduce((state, x) => state + x, 0)
    6
    ```

    * `reduceRight<U>(callback: (state: U, element: T, index: number, array: T[]) => U, firstState?: U): U` 🔒 <sup>ES5</sup>

    Works like `.reduce()`, but visits the array elements backward, starting with the last element.

    ```repl
    > [1, 2, 3].reduceRight((state, x) => state + String(x), '')
    '321'
    ```

    * `reverse(): this` ✏️ <sup>ES1</sup>

    Rearranges the elements of the array so that they are in reverse order and then returns `this`.

    ```repl
    > const arr = ['a', 'b', 'c'];
    > arr.reverse()
    [ 'c', 'b', 'a' ]
    > arr
    [ 'c', 'b', 'a' ]
    ```

    * `shift(): T | undefined` ✏️ <sup>ES3</sup>

    Removes and returns the first element of the array. The opposite of `.unshift()`.

    ```repl
    > const arr = ['a', 'b', 'c'];
    > arr.shift()
    'a'
    > arr
    [ 'b', 'c' ]
    ```

    * `slice(start=0, end=this.length): T[]` 🔒 <sup>ES3</sup>

    Returns a new array, with the elements of `this` whose indices are between (incl.) `start` and (excl.) `end`.

    ```repl
    > ['a', 'b', 'c', 'd'].slice(1, 3)
    [ 'b', 'c' ]
    > ['a', 'b'].slice() // shallow copy
    [ 'a', 'b' ]
    ```

    * `some(callback: (value: T, index: number, array: Array<T>) => boolean, thisArg?: any): boolean` 🔒 <sup>ES5</sup>

    Returns `true` if `callback` returns `true` for at least one element. Stops as soon as it receives `true`. Math: ∃

    ```repl
    > [1, 2, 3].some(x => x < 0)
    false
    > [1, -2, 3].some(x => x < 0)
    true
    ```

    * `sort(compareFn?: (a: T, b: T) => number): this` ✏️ <sup>ES1</sup>

    Sorts the array and returns `this`. The order in which to sort is specified via `compareFn`, which returns a number that is:

    * Negative if `a < b` (mnemonic: negative = less than zero)
    * Zero if `a === b`
    * Positive if `a > b`

    ```repl
    > [3, 1, 2].sort((a, b) => a - b)
    [ 1, 2, 3 ]
    > ['b', 'a', 'c'].sort((a, b) => a < b ? -1 : a > b ? +1 : 0)
    [ 'a', 'b', 'c' ]
    ```

    * `splice(start: number, deleteCount=this.length-start, ...items: T[]): T[]` ✏️ <sup>ES3</sup>

    At index `start`, it removes `deleteCount` elements and inserts the `items`. It returns the deleted elements.

    ```repl
    > const arr = ['a', 'b', 'c', 'd'];
    > arr.splice(1, 2, 'x', 'y')
    [ 'b', 'c' ]
    > arr
    [ 'a', 'x', 'y', 'd' ]
    ```

    * `toString(): string` 🔒 <sup>ES1</sup>

    Returns a string with string versions of all elements, separated by commas.

    ```repl
    > [1, 2, 3].toString()
    '1,2,3'
    > ['a', 'b', 'c'].toString()
    'a,b,c'
    > [].toString()
    ''
    ```

    * `unshift(...items: T[]): number` ✏️ <sup>ES3</sup>

    Inserts the `items` at the beginning of this array and returns the length of `this` after the modification.

    ```repl
    > const arr = ['c', 'd'];
    > arr.unshift('e', 'f')
    4
    > arr
    [ 'e', 'f', 'c', 'd' ]
    ```

    ## More information

    * Array methods of various ECMAScript versions in detail: http://exploringjs.com
    * Holes and array methods: Sect. “[Array operations and holes](http://exploringjs.com/es6/ch_arrays.html#_array-operations-and-holes)” in “Exploring ES6”.

    <!-- TODO: @@iterable, constructor, .length -->

    ## Sources

    * https://github.com/Microsoft/TypeScript/blob/master/lib/lib.es6.d.ts
    * MDN
    * ECMAScript spec
    This content moved here: https://exploringjs.com/impatient-js/ch_arrays.html#quickref-arrays
  2. rauschma revised this gist Apr 5, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ Legend:

    `Array<T>.prototype.*`:

    * `concat(...items: Array<T[] | T>: T[]` 🔒 <sup>ES3</sup>
    * `concat(...items: Array<T[] | T>): T[]` 🔒 <sup>ES3</sup>

    Returns a new array that is the concatenation of `this` and all `items`. Non-array parameters are treated as if they were arrays with single elements.

  3. rauschma revised this gist Apr 3, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -97,7 +97,7 @@ Legend:

    * `includes(searchElement: T, fromIndex=0): boolean` 🔒 <sup>ES2016</sup>

    Returns `true` if `searchElement` is an element and `false`, otherwise.
    Returns `true` if `searchElement` SameValueZero-equal to an element and `false`, otherwise. SameValueZero-equal means: strictly equal, but `NaN` is also equal to itself.

    ```repl
    > [0, 1, 2].includes(1)
    @@ -141,7 +141,7 @@ Legend:

    * `lastIndexOf(searchElement: T, fromIndex=this.length-1): number` 🔒 <sup>ES5</sup>

    Returns the index of the first element that is strictly equal to `searchElement`. Returns `-1` if there is no such element. Starts searching at index `fromIndex`, visiting preceding indices next.
    Returns the index of the last element that is strictly equal to `searchElement`. Returns `-1` if there is no such element. Starts searching at index `fromIndex`, visiting preceding indices next.

    ```repl
    > ['a', 'b', 'a'].lastIndexOf('a')
  4. rauschma revised this gist Apr 2, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ Legend:

    `Array<T>.prototype.*`:

    * `concat(...items: (T | Array<T>)[]): T[]` 🔒 <sup>ES3</sup>
    * `concat(...items: Array<T[] | T>: T[]` 🔒 <sup>ES3</sup>

    Returns a new array that is the concatenation of `this` and all `items`. Non-array parameters are treated as if they were arrays with single elements.

  5. rauschma revised this gist Apr 2, 2018. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,11 @@
    # `Array<T>`

    `Array<T>.prototype.*`
    Legend:

    * ✏️ method changes `this`.
    * 🔒 method does not change `this`.

    `Array<T>.prototype.*`:

    * `concat(...items: (T | Array<T>)[]): T[]` 🔒 <sup>ES3</sup>

  6. rauschma revised this gist Apr 2, 2018. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -300,7 +300,10 @@
    [ 'e', 'f', 'c', 'd' ]
    ```

    How holes are handled is described in Sect. “[Array operations and holes](http://exploringjs.com/es6/ch_arrays.html#_array-operations-and-holes)” in “Exploring ES6”.
    ## More information

    * Array methods of various ECMAScript versions in detail: http://exploringjs.com
    * Holes and array methods: Sect. “[Array operations and holes](http://exploringjs.com/es6/ch_arrays.html#_array-operations-and-holes)” in “Exploring ES6”.

    <!-- TODO: @@iterable, constructor, .length -->

  7. rauschma revised this gist Apr 2, 2018. 1 changed file with 35 additions and 4 deletions.
    39 changes: 35 additions & 4 deletions api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -263,11 +263,42 @@
    [ 'a', 'b', 'c' ]
    ```

    * `splice`
    * `toLocaleString`
    * `toString`
    * `splice(start: number, deleteCount=this.length-start, ...items: T[]): T[]` ✏️ <sup>ES3</sup>

    At index `start`, it removes `deleteCount` elements and inserts the `items`. It returns the deleted elements.

    ```repl
    > const arr = ['a', 'b', 'c', 'd'];
    > arr.splice(1, 2, 'x', 'y')
    [ 'b', 'c' ]
    > arr
    [ 'a', 'x', 'y', 'd' ]
    ```

    * `toString(): string` 🔒 <sup>ES1</sup>

    Returns a string with string versions of all elements, separated by commas.

    ```repl
    > [1, 2, 3].toString()
    '1,2,3'
    > ['a', 'b', 'c'].toString()
    'a,b,c'
    > [].toString()
    ''
    ```

    * `unshift(...items: T[]): number` ✏️ <sup>ES3</sup>
    * `values(): Iterable<T>`

    Inserts the `items` at the beginning of this array and returns the length of `this` after the modification.

    ```repl
    > const arr = ['c', 'd'];
    > arr.unshift('e', 'f')
    4
    > arr
    [ 'e', 'f', 'c', 'd' ]
    ```

    How holes are handled is described in Sect. “[Array operations and holes](http://exploringjs.com/es6/ch_arrays.html#_array-operations-and-holes)” in “Exploring ES6”.

  8. rauschma revised this gist Apr 2, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -271,7 +271,7 @@

    How holes are handled is described in Sect. “[Array operations and holes](http://exploringjs.com/es6/ch_arrays.html#_array-operations-and-holes)” in “Exploring ES6”.

    <!-- TODO: @@iterable, constructor, .length -
    <!-- TODO: @@iterable, constructor, .length -->

    ## Sources

  9. rauschma revised this gist Apr 2, 2018. 1 changed file with 62 additions and 6 deletions.
    68 changes: 62 additions & 6 deletions api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -202,15 +202,71 @@
    '321'
    ```

    * `reverse`
    * `shift`
    * `slice`
    * `some`
    * `sort`
    * `reverse(): this` ✏️ <sup>ES1</sup>

    Rearranges the elements of the array so that they are in reverse order and then returns `this`.

    ```repl
    > const arr = ['a', 'b', 'c'];
    > arr.reverse()
    [ 'c', 'b', 'a' ]
    > arr
    [ 'c', 'b', 'a' ]
    ```

    * `shift(): T | undefined` ✏️ <sup>ES3</sup>

    Removes and returns the first element of the array. The opposite of `.unshift()`.

    ```repl
    > const arr = ['a', 'b', 'c'];
    > arr.shift()
    'a'
    > arr
    [ 'b', 'c' ]
    ```

    * `slice(start=0, end=this.length): T[]` 🔒 <sup>ES3</sup>

    Returns a new array, with the elements of `this` whose indices are between (incl.) `start` and (excl.) `end`.

    ```repl
    > ['a', 'b', 'c', 'd'].slice(1, 3)
    [ 'b', 'c' ]
    > ['a', 'b'].slice() // shallow copy
    [ 'a', 'b' ]
    ```

    * `some(callback: (value: T, index: number, array: Array<T>) => boolean, thisArg?: any): boolean` 🔒 <sup>ES5</sup>

    Returns `true` if `callback` returns `true` for at least one element. Stops as soon as it receives `true`. Math: ∃

    ```repl
    > [1, 2, 3].some(x => x < 0)
    false
    > [1, -2, 3].some(x => x < 0)
    true
    ```

    * `sort(compareFn?: (a: T, b: T) => number): this` ✏️ <sup>ES1</sup>

    Sorts the array and returns `this`. The order in which to sort is specified via `compareFn`, which returns a number that is:

    * Negative if `a < b` (mnemonic: negative = less than zero)
    * Zero if `a === b`
    * Positive if `a > b`

    ```repl
    > [3, 1, 2].sort((a, b) => a - b)
    [ 1, 2, 3 ]
    > ['b', 'a', 'c'].sort((a, b) => a < b ? -1 : a > b ? +1 : 0)
    [ 'a', 'b', 'c' ]
    ```

    * `splice`
    * `toLocaleString`
    * `toString`
    * `unshift`
    * `unshift(...items: T[]): number` ✏️ <sup>ES3</sup>
    * `values(): Iterable<T>`

    How holes are handled is described in Sect. “[Array operations and holes](http://exploringjs.com/es6/ch_arrays.html#_array-operations-and-holes)” in “Exploring ES6”.
  10. rauschma revised this gist Apr 2, 2018. 1 changed file with 32 additions and 3 deletions.
    35 changes: 32 additions & 3 deletions api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -170,9 +170,38 @@
    [ 'a', 'b' ]
    ```

    * `push`
    * `reduce`
    * `reduceRight`
    * `push(...items: T[]): number` ✏️ <sup>ES3</sup>

    Adds adds zero or more `items` to the end of the array. That is, it treats the end of the array as a stack. The return value is the length of `this` after the change.

    ```repl
    > const arr = ['a', 'b'];
    > arr.push('c', 'd')
    4
    > arr
    [ 'a', 'b', 'c', 'd' ]
    ```

    * `reduce<U>(callback: (state: U, element: T, index: number, array: T[]) => U, firstState?: U): U` 🔒 <sup>ES5</sup>

    The `callback` computes the next state, given the current state and an `element` of the array. `.reduce()` feeds it the array elements, starting at index 0, going forward. If no `firstState` is provided, the array element at index 0 is used, instead. The last state is the result of `.reduce()`.

    ```repl
    > [1, 2, 3].reduce((state, x) => state + String(x), '')
    '123'
    > [1, 2, 3].reduce((state, x) => state + x, 0)
    6
    ```

    * `reduceRight<U>(callback: (state: U, element: T, index: number, array: T[]) => U, firstState?: U): U` 🔒 <sup>ES5</sup>

    Works like `.reduce()`, but visits the array elements backward, starting with the last element.

    ```repl
    > [1, 2, 3].reduceRight((state, x) => state + String(x), '')
    '321'
    ```

    * `reverse`
    * `shift`
    * `slice`
  11. rauschma revised this gist Apr 2, 2018. 1 changed file with 107 additions and 33 deletions.
    140 changes: 107 additions & 33 deletions api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -41,55 +41,129 @@
    ```

    * `fill(value: T, start=0, end=this.length): this` ✏️ <sup>ES6</sup>
    * Assigns `value` to every index.
    * `[0, 1, 2].fill('a') → [ 'a', 'a', 'a' ]`

    Assigns `value` to every index.

    ```repl
    > [0, 1, 2].fill('a')
    [ 'a', 'a', 'a' ]
    ```

    * `filter(callback: (value: T, index: number, array: Array<T>) => any, thisArg?: any): T[]` 🔒 <sup>ES5</sup>
    * Returns an array with only those elements for which `callback` returns `true`.
    * `[1, -2, 3].filter(x => x > 0) → [ 1, 3 ]`

    Returns an array with only those elements for which `callback` returns `true`.

    ```repl
    > [1, -2, 3].filter(x => x > 0)
    [ 1, 3 ]
    ```

    * `find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined` 🔒 <sup>ES6</sup>
    * The result is the first element for which `predicate` returns `true`. If it never does, the result is `undefined`.
    * `[1, -2, 3].find(x => x < 0) → -2`
    * `[1, 2, 3].find(x => x < 0) → undefined`

    The result is the first element for which `predicate` returns `true`. If it never does, the result is `undefined`.

    ```repl
    > [1, -2, 3].find(x => x < 0)
    -2
    > [1, 2, 3].find(x => x < 0)
    undefined
    ```

    * `findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number` 🔒 <sup>ES6</sup>
    * The result is the index of the first element for which `predicate` returns `true`. If it never does, the result is `-1`.
    * `[1, -2, 3].findIndex(x => x < 0) → 1`
    * `[1, 2, 3].findIndex(x => x < 0) → -1`

    The result is the index of the first element for which `predicate` returns `true`. If it never does, the result is `-1`.

    ```repl
    > [1, -2, 3].findIndex(x => x < 0)
    1
    > [1, 2, 3].findIndex(x => x < 0)
    -1
    ```

    * `forEach(callback: (value: T, index: number, array: Array<T>) => void, thisArg?: any): void` 🔒 <sup>ES5</sup>
    * Calls `callback` for each element.
    * `['a', 'b'].forEach((x, i) => console.log(x, i))`

    Calls `callback` for each element.

    ```js
    ['a', 'b'].forEach((x, i) => console.log(x, i))
    // 'a' 0
    // 'b' 1
    ```

    * `includes(searchElement: T, fromIndex=0): boolean` 🔒 <sup>ES2016</sup>
    * Returns `true` if `searchElement` is an element and `false`, otherwise.
    * `[0, 1, 2].includes(1) → true`
    * `[0, 1, 2].includes(5) → false`

    Returns `true` if `searchElement` is an element and `false`, otherwise.

    ```repl
    > [0, 1, 2].includes(1)
    true
    > [0, 1, 2].includes(5)
    false
    ```

    * `indexOf(searchElement: T, fromIndex=0): number` 🔒 <sup>ES5</sup>
    * Returns the index of the first element that is strictly equal to `searchElement`. Returns `-1` if there is no such element. Starts searching at index `fromIndex`, visiting subsequent indices next.
    * `['a', 'b', 'a'].indexOf('a') → 0`
    * `['a', 'b', 'a'].indexOf('a', 1) → 2`
    * `['a', 'b', 'a'].indexOf('c') → -1`

    Returns the index of the first element that is strictly equal to `searchElement`. Returns `-1` if there is no such element. Starts searching at index `fromIndex`, visiting subsequent indices next.

    ```repl
    > ['a', 'b', 'a'].indexOf('a')
    0
    > ['a', 'b', 'a'].indexOf('a', 1)
    2
    > ['a', 'b', 'a'].indexOf('c')
    -1
    ```

    * `join(separator = ','): string` 🔒 <sup>ES1</sup>
    * Creates a string by concatenating string representations of all elements, separating by `separator`.
    * `['a', 'b', 'c'].join() → 'a,b,c'`
    * `['a', 'b', 'c'].join('##') → 'a##b##c'`

    Creates a string by concatenating string representations of all elements, separating by `separator`.

    ```repl
    > ['a', 'b', 'c'].join()
    'a,b,c'
    > ['a', 'b', 'c'].join('##')
    'a##b##c'
    ```

    * `keys(): Iterable<number>` 🔒 <sup>ES6</sup>
    * Returns an iterable over the keys of the array.
    * `[...['a', 'b'].keys()] → [ 0, 1 ]`

    Returns an iterable over the keys of the array.

    ```repl
    > [...['a', 'b'].keys()]
    [ 0, 1 ]
    ```

    * `lastIndexOf(searchElement: T, fromIndex=this.length-1): number` 🔒 <sup>ES5</sup>
    * Returns the index of the first element that is strictly equal to `searchElement`. Returns `-1` if there is no such element. Starts searching at index `fromIndex`, visiting preceding indices next.
    * `['a', 'b', 'a'].lastIndexOf('a') → 2`
    * `['a', 'b', 'a'].lastIndexOf('a', 1) → 0`
    * `['a', 'b', 'a'].lastIndexOf('c') → -1`

    Returns the index of the first element that is strictly equal to `searchElement`. Returns `-1` if there is no such element. Starts searching at index `fromIndex`, visiting preceding indices next.

    ```repl
    > ['a', 'b', 'a'].lastIndexOf('a')
    2
    > ['a', 'b', 'a'].lastIndexOf('a', 1)
    0
    > ['a', 'b', 'a'].lastIndexOf('c')
    -1
    ```

    * `map<U>(callback: (value: T, index: number, array: ReadonlyArray<T>) => U, thisArg?: any): U[]` 🔒 <sup>ES5</sup>
    * Returns a new array, in which every element is the result of `callback` being applied to the corresponding element of `this`.
    * `[1, 2, 3].map(x => x * 2) → [ 2, 4, 6 ]`
    * `['a', 'b', 'c'].map((x, i) => i) → [ 0, 1, 2 ]`

    Returns a new array, in which every element is the result of `callback` being applied to the corresponding element of `this`.

    ```repl
    > [1, 2, 3].map(x => x * 2)
    [ 2, 4, 6 ]
    > ['a', 'b', 'c'].map((x, i) => i)
    [ 0, 1, 2 ]
    ```

    * `pop(): T | undefined` ✏️ <sup>ES3</sup>

    Treats the end of the array as a stack and removes the last element.
    Removes and returns the last element of the array. That is, it treats the end of the array as a stack.

    ```repl
    > const arr = ['a', 'b', 'c'];
    undefined
    > arr.pop()
    'c'
    > arr
  12. rauschma revised this gist Apr 2, 2018. 1 changed file with 63 additions and 39 deletions.
    102 changes: 63 additions & 39 deletions api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -2,76 +2,100 @@

    `Array<T>.prototype.*`

    * `concat(...items: (T | Array<T>)[]): T[]` 🔒
    * Returns a new array that is the concatenation of `this` and all `items`. Non-array parameters are treated as if they were arrays with single elements.
    * ES3
    * `['a'].concat('b', ['c', 'd']) → [ 'a', 'b', 'c', 'd' ]`
    * `copyWithin(target: number, start: number, end?: number): this` ✏️
    * Copies the elements whose indices range from `start` to (excl.) `end` to indices starting with `target`. Overlapping is handled correctly.
    * ES6
    * `['a', 'b', 'c', 'd'].copyWithin(0, 2, 4) → [ 'c', 'd', 'c', 'd' ]`
    * `entries(): Iterable<[number, T]>` 🔒
    * Returns an iterable over [index, element] pairs.
    * ES6
    * `Array.from(['a', 'b'].entries()) → [ [ 0, 'a' ], [ 1, 'b' ] ]`
    * `every(callback: (value: T, index: number, array: Array<T>) => boolean, thisArg?: any): boolean` 🔒
    * Returns `true` if `callback` returns `true` for every element. Stops as soon as it receives `false`. Math: ∀
    * ES5
    * `[1, 2, 3].every(x => x > 0) → true`
    * `[1, -2, 3].every(x => x > 0) → false`
    * `fill(value: T, start?: number, end?: number): this` ✏️
    * `concat(...items: (T | Array<T>)[]): T[]` 🔒 <sup>ES3</sup>

    Returns a new array that is the concatenation of `this` and all `items`. Non-array parameters are treated as if they were arrays with single elements.

    ```repl
    > ['a'].concat('b', ['c', 'd'])
    [ 'a', 'b', 'c', 'd' ]
    ```

    * `copyWithin(target: number, start: number, end=this.length): this` ✏️ <sup>ES6</sup>

    Copies the elements whose indices range from `start` to (excl.) `end` to indices starting with `target`. Overlapping is handled correctly.

    ```repl
    > ['a', 'b', 'c', 'd'].copyWithin(0, 2, 4)
    [ 'c', 'd', 'c', 'd' ]
    ```

    * `entries(): Iterable<[number, T]>` 🔒 <sup>ES6</sup>

    Returns an iterable over [index, element] pairs.

    ```repl
    > Array.from(['a', 'b'].entries())
    [ [ 0, 'a' ], [ 1, 'b' ] ]
    ```

    * `every(callback: (value: T, index: number, array: Array<T>) => boolean, thisArg?: any): boolean` 🔒 <sup>ES5</sup>

    Returns `true` if `callback` returns `true` for every element. Stops as soon as it receives `false`. Math: ∀

    ```repl
    > [1, 2, 3].every(x => x > 0)
    true
    > [1, -2, 3].every(x => x > 0)
    false
    ```

    * `fill(value: T, start=0, end=this.length): this` ✏️ <sup>ES6</sup>
    * Assigns `value` to every index.
    * ES6
    * `[0, 1, 2].fill('a') → [ 'a', 'a', 'a' ]`
    * `filter(callback: (value: T, index: number, array: Array<T>) => any, thisArg?: any): T[]` 🔒
    * `filter(callback: (value: T, index: number, array: Array<T>) => any, thisArg?: any): T[]` 🔒 <sup>ES5</sup>
    * Returns an array with only those elements for which `callback` returns `true`.
    * ES5
    * `[1, -2, 3].filter(x => x > 0) → [ 1, 3 ]`
    * `find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined` 🔒
    * `find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined` 🔒 <sup>ES6</sup>
    * The result is the first element for which `predicate` returns `true`. If it never does, the result is `undefined`.
    * ES6
    * `[1, -2, 3].find(x => x < 0) → -2`
    * `[1, 2, 3].find(x => x < 0) → undefined`
    * `findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number` 🔒
    * `findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number` 🔒 <sup>ES6</sup>
    * The result is the index of the first element for which `predicate` returns `true`. If it never does, the result is `-1`.
    * ES6
    * `[1, -2, 3].findIndex(x => x < 0) → 1`
    * `[1, 2, 3].findIndex(x => x < 0) → -1`
    * `forEach(callback: (value: T, index: number, array: Array<T>) => void, thisArg?: any): void` 🔒
    * `forEach(callback: (value: T, index: number, array: Array<T>) => void, thisArg?: any): void` 🔒 <sup>ES5</sup>
    * Calls `callback` for each element.
    * ES5
    * `['a', 'b'].forEach((x, i) => console.log(x, i))`
    * `includes(searchElement: T, fromIndex?: number): boolean` 🔒
    * `includes(searchElement: T, fromIndex=0): boolean` 🔒 <sup>ES2016</sup>
    * Returns `true` if `searchElement` is an element and `false`, otherwise.
    * ES2016
    * `[0, 1, 2].includes(1) → true`
    * `[0, 1, 2].includes(5) → false`
    * `indexOf(searchElement: T, fromIndex=0): number` 🔒
    * `indexOf(searchElement: T, fromIndex=0): number` 🔒 <sup>ES5</sup>
    * Returns the index of the first element that is strictly equal to `searchElement`. Returns `-1` if there is no such element. Starts searching at index `fromIndex`, visiting subsequent indices next.
    * ES5
    * `['a', 'b', 'a'].indexOf('a') → 0`
    * `['a', 'b', 'a'].indexOf('a', 1) → 2`
    * `['a', 'b', 'a'].indexOf('c') → -1`
    * `join(separator = ','): string` 🔒
    * `join(separator = ','): string` 🔒 <sup>ES1</sup>
    * Creates a string by concatenating string representations of all elements, separating by `separator`.
    * ES1
    * `['a', 'b', 'c'].join() → 'a,b,c'`
    * `['a', 'b', 'c'].join('##') → 'a##b##c'`
    * `keys(): Iterable<number>` 🔒
    * `keys(): Iterable<number>` 🔒 <sup>ES6</sup>
    * Returns an iterable over the keys of the array.
    * ES6
    * `[...['a', 'b'].keys()] → [ 0, 1 ]`
    * `lastIndexOf(searchElement: T, fromIndex=this.length-1): number` 🔒
    * `lastIndexOf(searchElement: T, fromIndex=this.length-1): number` 🔒 <sup>ES5</sup>
    * Returns the index of the first element that is strictly equal to `searchElement`. Returns `-1` if there is no such element. Starts searching at index `fromIndex`, visiting preceding indices next.
    * ES5
    * `['a', 'b', 'a'].lastIndexOf('a') → 2`
    * `['a', 'b', 'a'].lastIndexOf('a', 1) → 0`
    * `['a', 'b', 'a'].lastIndexOf('c') → -1`
    * `map<U>(callback: (value: T, index: number, array: ReadonlyArray<T>) => U, thisArg?: any): U[]` 🔒 <sup>ES5</sup>
    * Returns a new array, in which every element is the result of `callback` being applied to the corresponding element of `this`.
    * `[1, 2, 3].map(x => x * 2) → [ 2, 4, 6 ]`
    * `['a', 'b', 'c'].map((x, i) => i) → [ 0, 1, 2 ]`

    * `pop(): T | undefined` ✏️ <sup>ES3</sup>

    Treats the end of the array as a stack and removes the last element.

    ```repl
    > const arr = ['a', 'b', 'c'];
    undefined
    > arr.pop()
    'c'
    > arr
    [ 'a', 'b' ]
    ```

    * `map`
    * `pop`
    * `push`
    * `reduce`
    * `reduceRight`
  13. rauschma revised this gist Apr 2, 2018. 1 changed file with 24 additions and 8 deletions.
    32 changes: 24 additions & 8 deletions api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -46,14 +46,30 @@
    * ES2016
    * `[0, 1, 2].includes(1) → true`
    * `[0, 1, 2].includes(5) → false`
    * `indexOf(searchElement: T, fromIndex?: number): number` 🔒
    * Return the index of the first element that is strictly equal to `searchElement`. Return `-1` if there is no such element. Start searching at index `fromIndex`.
    * `indexOf(searchElement: T, fromIndex=0): number` 🔒
    * Returns the index of the first element that is strictly equal to `searchElement`. Returns `-1` if there is no such element. Starts searching at index `fromIndex`, visiting subsequent indices next.
    * ES5
    * `[0, 1, 2].indexOf(1) → 1`
    * `[0, 1, 2].indexOf(5) → -1`
    * `join`
    * `keys`
    * `lastIndexOf`
    * `['a', 'b', 'a'].indexOf('a') → 0`
    * `['a', 'b', 'a'].indexOf('a', 1) → 2`
    * `['a', 'b', 'a'].indexOf('c') → -1`
    * `join(separator = ','): string` 🔒
    * Creates a string by concatenating string representations of all elements, separating by `separator`.
    * ES1
    * `['a', 'b', 'c'].join() → 'a,b,c'`
    * `['a', 'b', 'c'].join('##') → 'a##b##c'`
    * `keys(): Iterable<number>` 🔒
    * Returns an iterable over the keys of the array.
    * ES6
    * `[...['a', 'b'].keys()] → [ 0, 1 ]`
    * `lastIndexOf(searchElement: T, fromIndex=this.length-1): number` 🔒
    * Returns the index of the first element that is strictly equal to `searchElement`. Returns `-1` if there is no such element. Starts searching at index `fromIndex`, visiting preceding indices next.
    * ES5
    * `['a', 'b', 'a'].lastIndexOf('a') → 2`
    * `['a', 'b', 'a'].lastIndexOf('a', 1) → 0`
    * `['a', 'b', 'a'].lastIndexOf('c') → -1`



    * `map`
    * `pop`
    * `push`
    @@ -68,7 +84,7 @@
    * `toLocaleString`
    * `toString`
    * `unshift`
    * `values`
    * `values(): Iterable<T>`

    How holes are handled is described in Sect. “[Array operations and holes](http://exploringjs.com/es6/ch_arrays.html#_array-operations-and-holes)” in “Exploring ES6”.

  14. rauschma revised this gist Apr 2, 2018. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -44,12 +44,13 @@
    * `includes(searchElement: T, fromIndex?: number): boolean` 🔒
    * Returns `true` if `searchElement` is an element and `false`, otherwise.
    * ES2016
    * `[0, 1, 2].includes(1) -> true`
    * `[0, 1, 2].includes(5) -> false`



    * `indexOf`
    * `[0, 1, 2].includes(1) → true`
    * `[0, 1, 2].includes(5) → false`
    * `indexOf(searchElement: T, fromIndex?: number): number` 🔒
    * Return the index of the first element that is strictly equal to `searchElement`. Return `-1` if there is no such element. Start searching at index `fromIndex`.
    * ES5
    * `[0, 1, 2].indexOf(1) → 1`
    * `[0, 1, 2].indexOf(5) → -1`
    * `join`
    * `keys`
    * `lastIndexOf`
  15. rauschma revised this gist Apr 2, 2018. 1 changed file with 21 additions and 21 deletions.
    42 changes: 21 additions & 21 deletions api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -2,48 +2,48 @@

    `Array<T>.prototype.*`

    * `concat(...items: (T | Array<T>)[]): T[]`
    * Non-destructively concatenates `this` and the parameters (which can be single elements or array of elements).
    * ES3, non-destructive
    * `concat(...items: (T | Array<T>)[]): T[]` 🔒
    * Returns a new array that is the concatenation of `this` and all `items`. Non-array parameters are treated as if they were arrays with single elements.
    * ES3
    * `['a'].concat('b', ['c', 'd']) → [ 'a', 'b', 'c', 'd' ]`
    * `copyWithin(target: number, start: number, end?: number): this`
    * `copyWithin(target: number, start: number, end?: number): this` ✏️
    * Copies the elements whose indices range from `start` to (excl.) `end` to indices starting with `target`. Overlapping is handled correctly.
    * ES6, destructive
    * ES6
    * `['a', 'b', 'c', 'd'].copyWithin(0, 2, 4) → [ 'c', 'd', 'c', 'd' ]`
    * `entries(): Iterable<[number, T]>`
    * `entries(): Iterable<[number, T]>` 🔒
    * Returns an iterable over [index, element] pairs.
    * ES6, non-destructive
    * ES6
    * `Array.from(['a', 'b'].entries()) → [ [ 0, 'a' ], [ 1, 'b' ] ]`
    * `every(callback: (value: T, index: number, array: Array<T>) => boolean, thisArg?: any): boolean`
    * `every(callback: (value: T, index: number, array: Array<T>) => boolean, thisArg?: any): boolean` 🔒
    * Returns `true` if `callback` returns `true` for every element. Stops as soon as it receives `false`. Math: ∀
    * ES5, non-destructive
    * ES5
    * `[1, 2, 3].every(x => x > 0) → true`
    * `[1, -2, 3].every(x => x > 0) → false`
    * `fill(value: T, start?: number, end?: number): this`
    * `fill(value: T, start?: number, end?: number): this` ✏️
    * Assigns `value` to every index.
    * ES6, destructive
    * ES6
    * `[0, 1, 2].fill('a') → [ 'a', 'a', 'a' ]`
    * `filter(callback: (value: T, index: number, array: Array<T>) => any, thisArg?: any): T[]`
    * `filter(callback: (value: T, index: number, array: Array<T>) => any, thisArg?: any): T[]` 🔒
    * Returns an array with only those elements for which `callback` returns `true`.
    * ES5, non-destructive
    * ES5
    * `[1, -2, 3].filter(x => x > 0) → [ 1, 3 ]`
    * `find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined`
    * `find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined` 🔒
    * The result is the first element for which `predicate` returns `true`. If it never does, the result is `undefined`.
    * ES6, non-destructive
    * ES6
    * `[1, -2, 3].find(x => x < 0) → -2`
    * `[1, 2, 3].find(x => x < 0) → undefined`
    * `findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number`
    * `findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number` 🔒
    * The result is the index of the first element for which `predicate` returns `true`. If it never does, the result is `-1`.
    * ES6, non-destructive
    * ES6
    * `[1, -2, 3].findIndex(x => x < 0) → 1`
    * `[1, 2, 3].findIndex(x => x < 0) → -1`
    * `forEach(callback: (value: T, index: number, array: Array<T>) => void, thisArg?: any): void`
    * `forEach(callback: (value: T, index: number, array: Array<T>) => void, thisArg?: any): void` 🔒
    * Calls `callback` for each element.
    * ES5, non-destructive
    * ES5
    * `['a', 'b'].forEach((x, i) => console.log(x, i))`
    * `includes(searchElement: T, fromIndex?: number): boolean`
    * `includes(searchElement: T, fromIndex?: number): boolean` 🔒
    * Returns `true` if `searchElement` is an element and `false`, otherwise.
    * ES2016, non-destructive
    * ES2016
    * `[0, 1, 2].includes(1) -> true`
    * `[0, 1, 2].includes(5) -> false`

  16. rauschma revised this gist Apr 2, 2018. 1 changed file with 13 additions and 3 deletions.
    16 changes: 13 additions & 3 deletions api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -33,12 +33,22 @@
    * `[1, -2, 3].find(x => x < 0) → -2`
    * `[1, 2, 3].find(x => x < 0) → undefined`
    * `findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number`
    * The result is the index of the first element for which `predicate` returns `true`. If it never does, the result is `-1`
    * The result is the index of the first element for which `predicate` returns `true`. If it never does, the result is `-1`.
    * ES6, non-destructive
    * `[1, -2, 3].findIndex(x => x < 0) → 1`
    * `[1, 2, 3].findIndex(x => x < 0) → -1`
    * `forEach`
    * `includes`
    * `forEach(callback: (value: T, index: number, array: Array<T>) => void, thisArg?: any): void`
    * Calls `callback` for each element.
    * ES5, non-destructive
    * `['a', 'b'].forEach((x, i) => console.log(x, i))`
    * `includes(searchElement: T, fromIndex?: number): boolean`
    * Returns `true` if `searchElement` is an element and `false`, otherwise.
    * ES2016, non-destructive
    * `[0, 1, 2].includes(1) -> true`
    * `[0, 1, 2].includes(5) -> false`



    * `indexOf`
    * `join`
    * `keys`
  17. rauschma revised this gist Apr 2, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    `Array<T>.prototype.*`

    * `concat(...items: (T | ConcatArray<T>)[]): T[]`
    * `concat(...items: (T | Array<T>)[]): T[]`
    * Non-destructively concatenates `this` and the parameters (which can be single elements or array of elements).
    * ES3, non-destructive
    * `['a'].concat('b', ['c', 'd']) → [ 'a', 'b', 'c', 'd' ]`
  18. rauschma revised this gist Apr 2, 2018. 1 changed file with 12 additions and 2 deletions.
    14 changes: 12 additions & 2 deletions api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -27,8 +27,16 @@
    * Returns an array with only those elements for which `callback` returns `true`.
    * ES5, non-destructive
    * `[1, -2, 3].filter(x => x > 0) → [ 1, 3 ]`
    * `find`
    * `findIndex`
    * `find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined`
    * The result is the first element for which `predicate` returns `true`. If it never does, the result is `undefined`.
    * ES6, non-destructive
    * `[1, -2, 3].find(x => x < 0) → -2`
    * `[1, 2, 3].find(x => x < 0) → undefined`
    * `findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number`
    * The result is the index of the first element for which `predicate` returns `true`. If it never does, the result is `-1`
    * ES6, non-destructive
    * `[1, -2, 3].findIndex(x => x < 0) → 1`
    * `[1, 2, 3].findIndex(x => x < 0) → -1`
    * `forEach`
    * `includes`
    * `indexOf`
    @@ -51,6 +59,8 @@
    * `unshift`
    * `values`

    How holes are handled is described in Sect. “[Array operations and holes](http://exploringjs.com/es6/ch_arrays.html#_array-operations-and-holes)” in “Exploring ES6”.

    <!-- TODO: @@iterable, constructor, .length -→
    ## Sources
  19. rauschma created this gist Apr 2, 2018.
    60 changes: 60 additions & 0 deletions api-cheatsheet-array.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    # `Array<T>`

    `Array<T>.prototype.*`

    * `concat(...items: (T | ConcatArray<T>)[]): T[]`
    * Non-destructively concatenates `this` and the parameters (which can be single elements or array of elements).
    * ES3, non-destructive
    * `['a'].concat('b', ['c', 'd']) → [ 'a', 'b', 'c', 'd' ]`
    * `copyWithin(target: number, start: number, end?: number): this`
    * Copies the elements whose indices range from `start` to (excl.) `end` to indices starting with `target`. Overlapping is handled correctly.
    * ES6, destructive
    * `['a', 'b', 'c', 'd'].copyWithin(0, 2, 4) → [ 'c', 'd', 'c', 'd' ]`
    * `entries(): Iterable<[number, T]>`
    * Returns an iterable over [index, element] pairs.
    * ES6, non-destructive
    * `Array.from(['a', 'b'].entries()) → [ [ 0, 'a' ], [ 1, 'b' ] ]`
    * `every(callback: (value: T, index: number, array: Array<T>) => boolean, thisArg?: any): boolean`
    * Returns `true` if `callback` returns `true` for every element. Stops as soon as it receives `false`. Math: ∀
    * ES5, non-destructive
    * `[1, 2, 3].every(x => x > 0) → true`
    * `[1, -2, 3].every(x => x > 0) → false`
    * `fill(value: T, start?: number, end?: number): this`
    * Assigns `value` to every index.
    * ES6, destructive
    * `[0, 1, 2].fill('a') → [ 'a', 'a', 'a' ]`
    * `filter(callback: (value: T, index: number, array: Array<T>) => any, thisArg?: any): T[]`
    * Returns an array with only those elements for which `callback` returns `true`.
    * ES5, non-destructive
    * `[1, -2, 3].filter(x => x > 0) → [ 1, 3 ]`
    * `find`
    * `findIndex`
    * `forEach`
    * `includes`
    * `indexOf`
    * `join`
    * `keys`
    * `lastIndexOf`
    * `map`
    * `pop`
    * `push`
    * `reduce`
    * `reduceRight`
    * `reverse`
    * `shift`
    * `slice`
    * `some`
    * `sort`
    * `splice`
    * `toLocaleString`
    * `toString`
    * `unshift`
    * `values`

    <!-- TODO: @@iterable, constructor, .length -→
    ## Sources
    * https://github.com/Microsoft/TypeScript/blob/master/lib/lib.es6.d.ts
    * MDN
    * ECMAScript spec