The Confusing World of Array Deletion in JavaScript
dev.to·3h·
Discuss: DEV
🔢const Generics
Preview
Report Post

One of JavaScript’s most controversial, yet quckly discussed subjects that goes beyond implicit type coercion (e.g., [] + {}) is handling arrays natively, specifically for programmers of other languages learning with the goal of actually understanding the language. While it’s one of the most popular programming languages in the world, its design choices around array manipulation have frustrated developers for decades, including newcomers. This is especially clear when trying to do something simple, such as removing an item from an array.

Let’s get into it!

The Different Approaches

Consider a simple basket of fruit:

const fruits = ['apple', 'banana', 'orange', 'grape', 'mango'];

Now, imagine wanting to remove ‘orange’ from this basket. JavaScript offers sever…

Similar Posts

Loading similar posts...