Today’s useful util isn’t going to be anything special. It’s something you’re already familiar with doing, but repurposing it into a more digestible use. That is removing an element at a position in an array. Since it’s something, you’re probably already familiar with, no need for any extra talking. Let’s just look at some code!
Array.prototype.remove = function() {
try {
const [specifier, amount, ...rest] = arguments;
const START = specifier || 0;
const STOP = amout || 1;
this.splice(START, STOP);
} catch (error) {
throw new Error('Looks like there was an issue removing your selection', error);
}
}
Looks good, works well, and can handle errors!