-
Notifications
You must be signed in to change notification settings - Fork 47.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add delete mutability helper #2906
Comments
You can do this with |
no, not at all. splice replaces items if there are only two parameters, or the third is undefined (e.g. by calling if there are more than three, … eeh, test it yourself. doesn’t work, that’s for sure. (make sure you use the browser console, not the JSBin console to see what elements are actually empty instead of set to “undefined”!) |
Oh sorry. I just realized what you meant and in fact I needed the exact same thing today (for objects). |
Would #2362 cover this? |
It's similar but has different behavior for arrays (from Mongo), setting items to |
Honestly I think My rule of thumb is following: if you can do something with Edit: I thought about it some more, and I'm in favor of non-holey |
yeah. it’s pretty strange that it special cases arrays without reason. i’d say we just change #2362 to unconditionally do |
We are handing over |
JS sparse arrays have some advantages.
Setting elements to
undefined
isn’t the same as deleting them, e.g.[1,,,3].map(console.log)
only prints1 3
, not1 undefined undefined 3
.Therefore there should be a mutability helper that returns a copy with a deleted entry:
PS: the same of course also applies to objects:
{foo: undefined}
isn’t the same as{}
.The text was updated successfully, but these errors were encountered: