Hello everyone,
Adding and removing elements from arrays is a must have skill in programming. It's one of the most basic things you learn in any language but it's the most essential as well. Without too much talking, let's dig in:
1- Adding Elements to Array.
push:
- Add an element to the end of an array.
unshift:
- Add an element to the beginning of an array.
splice:
- Add an element to the middle of an array.
Full explanation with example below 👇
2- Removing Elements to Array.
pop:
- Remove the last element of an array.
shift:
- Remove the first element of an array.
splice:
- Remove elements from the middle of an array.
Support me:
- Leave a reaction if you're happy with the article.
- Leave a comment if you have a constructive feedback or hate that I explained the logic in pictures.
Thanks for reading.