Removing value from array on specific location
This question already has an answer here:
You are using elements.slice(R3,1)
wrong. Second argument means not the length of the array you want to get, but the zero-based index of the element when slice method should stop. So your code is saying "Give me elements from index R3 till index 1", and the only one time when it will work: elements.slice(0, 1)
. If you just need to get one element - use elements[R1]
. If you need to get array with one element you can keep using slice with elements.slice(R1, R1 + 1);
上一篇: Push()的对面; (拼接解释)
下一篇: 从特定位置的数组中删除值