Skip to content

Instantly share code, notes, and snippets.

@toxi-kb
Created February 25, 2020 13:54
Show Gist options
  • Select an option

  • Save toxi-kb/397efab0ba525985fa59111d8f7ae0df to your computer and use it in GitHub Desktop.

Select an option

Save toxi-kb/397efab0ba525985fa59111d8f7ae0df to your computer and use it in GitHub Desktop.
const arr = [1, 0, 2, 3, 1, 0];
// Oops, we have an empty array
const newArray = arr.filter(item => {
if (item === 0) { return item }
});
// This works properly
const filteredArray = arr.filter(item => item === 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment