-
Notifications
You must be signed in to change notification settings - Fork 49.1k
Closed
Description
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 prints 1 3
, not 1 undefined undefined 3
.
Therefore there should be a mutability helper that returns a copy with a deleted entry:
{ update } = React.addons
let a = [1,,,2,,3]
let b = update(a, {$delete: 1})
console.log(a) // → [1, undefined×2, 2, undefined×1, 3]
console.log(b) // → [1, undefined×4, 3]
PS: the same of course also applies to objects: {foo: undefined}
isn’t the same as {}
.
Metadata
Metadata
Assignees
Labels
No labels