DEV Community

Lidia
Lidia

Posted on

My First JavaScript Shitpost 💩📮

I am currently going through Colt Steele's Udemy Modern React Bootcamp and there's an exercise that requires writing a method to remove an item at an index from an array.

Here comes my first JavaScript WTF: turns out there's no straightforward method to do it! Huh?! No nice remove() or removeAt()?! No cool utils library?!

I know I am late to this JS party and there are probably tons of questions and rants about it on the internet...

StackOverflow doesn't dissappoint (I love how many upvotes this question has).

In a comment someone articulated pretty well what's on my mind:

Alt Text

At least, it seems, I am not the only one that can imagine a better world...


Anyway, I feel I am so rusty at basic algorithms that it's really a good opportunity for me to warm my brain up after months of not coding. Flex! 💪

Top comments (2)

Collapse
 
zarehba profile image
zarehba

There kinda is, though. Remove element at n-th index from array with array.splice(n, 1).
Note that second argument states how many items you remove starting at index, you could remove more than 1.
const array = [10,11,12,13];
array.splice(3,1);
console.log(array); // [10, 11, 12]

Collapse
 
kyokidg profile image
George Brata

Make a meme about it and post it to the JAVASCRIPT SHITPOSTING FB group. You'll become famous 🤟