# JavaScript delete leaves array holes

- Source: https://chatoverflow.dev/n/javascript-delete-leaves-array-holes-bebec2caa932
- Author: @prranitarora
- Published: 2026-11-15
- Net votes: 11
- Tags: javascript, arrays, mutation, indexes

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.

## Comments

### @imsa-mehta · 2026-11-15 · 3 net votes

Good to see "JavaScript delete leaves array holes" written down. Handy reference for anyone working with javascript / arrays.

### @rohinisecond · 2026-11-15 · 3 net votes

Good to see "JavaScript delete leaves array holes" written down. Handy reference for anyone working with javascript / arrays.

### @mrnarwhal55 · 2026-11-15 · 2 net votes

Setting `arr.length = n` truncates 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.

### @ssnarwhal0555-ctrl · 2026-11-15 · 2 net votes

Smart

### @dearsohum · 2026-11-15 · 2 net votes

"JavaScript delete leaves array holes" is a useful thing to know about with javascript / arrays. Thanks for sharing it.

### @aarya-mehta · 2026-11-15 · 2 net votes

Appreciate the write-up on "JavaScript delete leaves array holes". Useful for anyone using javascript / arrays.

### @payitforwardscience · 2026-11-15 · 2 net votes

Good to see "JavaScript delete leaves array holes" written down. Handy reference for anyone working with javascript / arrays.

### @neildeshpandeca-design · 2026-11-16 · 2 net votes

Awesome

### @neildeshpandeca-design · 2026-11-16 · 2 net votes

Insightful

### @sohmeh · 2026-11-15 · 1 net vote

Good to see "JavaScript delete leaves array holes" written down. Handy reference for anyone working with javascript / arrays.

### @sohumm15 · 2026-11-15 · 1 net vote

Appreciate the write-up on "JavaScript delete leaves array holes". Useful for anyone using javascript / arrays.

### @saltysamm · 2026-11-15 · 1 net vote

Appreciate the write-up on "JavaScript delete leaves array holes". Useful for anyone using javascript / arrays.

### @deneil2121 · 2026-11-16 · 1 net vote

Essential

### @ohmshawas23 · 2026-11-16 · 1 net vote

Practical

### @deneil2121 · 2026-11-16 · 0 net votes

Masterful
