Function description: Insert elements into the array or delete elements from the array. Incoming parameter description: Start:. If the value is greater than the length of the array, insert it at the end of the array. If the starting value is less than 0, count from the end of the array. ex: -3 means the starting position of insertion is the third from the bottom of the array. location. deleteCount:
The number of array elements to be deleted, 0 means only inserting elements without deleting them. Item1n: Element to be inserted. example: var a = [1,2,3,4,5,6,7,8]; a.splice(4); a.splice(1,2); a.splice(1,1); Explanation: The final a array is [1], the first line assigns bot dataset the a array [1,2,3,4,5,6,7,8] value, the second line takes out all elements after the fourth position of the a array, So the a array will become [1,2,3,4], and the return value of splice is the data retrieved from the a array, which is [5,6,7,8].
The third line retrieves the first position of the a array. The next two elements, so the a array will become [1,4], and the return value of splice is the data taken out of the a array, which is [2,3]. The last line takes out one element after the first position of the a array, So the a array will become [1], and the return value of splice is the data taken out of the a array, which is [4]. Example 2: var a = [1,2,3,4,5]; a.splice(2,0,'Message','NAS'); a.splice(2,2,[1,2],3); Explanation: The last a array is [1,2,[1,2],3,3,4,5], and the first row assigns the a array [1,2,3,4,5,6,7,8] value , the first parameter passed in in the second line is 2,