Skip to content

Instantly share code, notes, and snippets.

@bobdobbalina
Last active June 3, 2020 14:33
Show Gist options
  • Save bobdobbalina/f4eba4a88559090d0745d378782f1172 to your computer and use it in GitHub Desktop.
Save bobdobbalina/f4eba4a88559090d0745d378782f1172 to your computer and use it in GitHub Desktop.
Javascript: Removing Falsy Values From Arrays
myArray.filter(Boolean);
// OR, IF YOU WANT TO MAKE MODIFICATIONS ON THE FLY
myArray
.map(item => {
// Do your changes and return the new item
})
.filter(Boolean);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment