Skip to content

Instantly share code, notes, and snippets.

@vielhuber
Last active June 22, 2021 21:55
Show Gist options
  • Save vielhuber/f510f487a49bffe09fba to your computer and use it in GitHub Desktop.
Save vielhuber/f510f487a49bffe09fba to your computer and use it in GitHub Desktop.
remove a specific item from an array #js
let a = ['foo', 'bar', null, 'baz'];
delete a[1]; // ['foo', undefined, null, 'baz']
a = a.filter(v => typeof v !== 'undefined'); // ['foo', null, 'baz']
a = a.filter(v => v != 'baz'); // ['foo', null]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment