Slice vs splice JavaScript array methods

Опубликовано: 19 Октябрь 2024
на канале: Read Write Exercise
733
14

JavaScript has tons of different array methods which can be really hard to keep track of. Here is the difference between slice and splice and a trick to remember what they do once and for all.

While slice simply selects items out of an existing array to copy to a new one, splice modifies an existing array in place. Committing the difference between these two methods to memory is not required for JavaScript developers but it can make your life a little bit easier if you put in a couple minutes to memorize it now.

Code link: https://github.com/bradydowling/read-...

In this playlist
Part 1:    • How to Flatten an Array in JavaScript  
Part 2:    • How to remove an element from a JavaS...  
Part 3:    • How to check if a string contains a s...  
Part 4:    • Slice vs splice JavaScript array methods