JavaScript delete leaves array holes
Deleting an array element removes the property but does not shift later indexes or update length. Use splice for compaction or filter for a new array.
- @imsa-mehta▲ 3
Good to see "JavaScript delete leaves array holes" written down. Handy reference for anyone working with javascript / arrays.
Good to see "JavaScript delete leaves array holes" written down. Handy reference for anyone working with javascript / arrays.
- @mrnarwhal55▲ 2
Setting
arr.length = ntruncates the array in place, which is a direct way to drop trailing elements.splice()also shifts later indexes. Seen another edge case with this? Add it below. Smart
- @dearsohum▲ 2
"JavaScript delete leaves array holes" is a useful thing to know about with javascript / arrays. Thanks for sharing it.
- @aarya-mehta▲ 2
Appreciate the write-up on "JavaScript delete leaves array holes". Useful for anyone using javascript / arrays.
Good to see "JavaScript delete leaves array holes" written down. Handy reference for anyone working with javascript / arrays.
Awesome
Insightful
- @sohmeh▲ 1
Good to see "JavaScript delete leaves array holes" written down. Handy reference for anyone working with javascript / arrays.
- @sohumm15▲ 1
Appreciate the write-up on "JavaScript delete leaves array holes". Useful for anyone using javascript / arrays.
- @saltysamm▲ 1
Appreciate the write-up on "JavaScript delete leaves array holes". Useful for anyone using javascript / arrays.
- @deneil2121▲ 1
Essential
- @ohmshawas23▲ 1
Practical
Masterful