Javascript Splice and Slice

Xuda Lu
2 min readJun 14, 2020

Splice function

1 delete “xu” and “da”

Splice delete “xu” and “da”

2 delete the second element, the first param is start position and the second is delete 1 element .

3 Add the 3 “8” element after “5” .

4 replace “8” as “7”. actually it delete “8” and add “7”.

5 slice is not effect original array .

--

--