Skip to content

Instantly share code, notes, and snippets.

@frostney
Last active December 18, 2015 12:39
Show Gist options
  • Save frostney/5784526 to your computer and use it in GitHub Desktop.
Save frostney/5784526 to your computer and use it in GitHub Desktop.
Safe and fast alternative for deleting items from arrays and objects
deleteItem = (obj, item) ->
if Array.isArray obj
i for i, num in obj when num isnt item
else
newObject = {}
newObject[key] = obj[key] for key of obj when key isnt item
newObject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment