Skip to content

Instantly share code, notes, and snippets.

@sefgit
Created March 11, 2025 23:24
Show Gist options
  • Save sefgit/2c759ee52faedf2ce299e8a793338abb to your computer and use it in GitHub Desktop.
Save sefgit/2c759ee52faedf2ce299e8a793338abb to your computer and use it in GitHub Desktop.
Node remove dict/array item
Object.prototype.removeItem = function (key) {
if (!this.hasOwnProperty(key))
return
if (isNaN(parseInt(key)) || !(this instanceof Array))
delete this[key]
else
this.splice(key, 1)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment