Skip to content

Instantly share code, notes, and snippets.

@pastparty
Last active June 18, 2018 09:48
Show Gist options
  • Select an option

  • Save pastparty/454ee435f300fd5f70732dfe936c33ea to your computer and use it in GitHub Desktop.

Select an option

Save pastparty/454ee435f300fd5f70732dfe936c33ea to your computer and use it in GitHub Desktop.
Which Array Function When?
/**
* Return one thing for each existing thing
*/
arr.map((item, index) => {})
/**
* Return only some of the existing things
*/
arr.filter((item, index) => {})
/**
* Return only one new thing
*/
arr.reduce((accumulator, item, index) => {})
/**
* Don't return anything, but do something with each existing thing
*/
arr.forEach((item, index) => {})
/**
* @see https://www.codementor.io/andrew565/which-array-function-when-jbtnzytza
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment