Created
March 11, 2025 23:24
-
-
Save sefgit/2c759ee52faedf2ce299e8a793338abb to your computer and use it in GitHub Desktop.
Node remove dict/array item
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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