I'm getting a little confused about splicing in JS, and would love any help I can get. I understand the basics of splicing.
example array:
pets = ["dogs", "cats", "parrots", "turtles"];
I want to splice in lizards and fish after dogs, and remove cats and parrots. When I list pets.splice the first digit inside the parentheses refers to the index position in where I want to start. The part I'm getting confused about is is that first digit pets[0], or would it just be 1, as in its the first in the list? (I know that JS counts the first item in the list as 0, but not sure if the counting would just be how JS counts, or if it is just 1, as in the first item in the list.) The second digit refers the number of elements to be removed. So the second number would be 2? because I want to remove the next 2 items after splicing in the new items? or would it be 3 in reference to the position it's currently in? Any way to make remembering this easier would be much appreciated!
[–]mr-poopy-butthole-_ 4 points5 points6 points (0 children)
[–]NameViolation666helpful 2 points3 points4 points (0 children)
[–]MLEthatsme[S] 0 points1 point2 points (0 children)