push() method: You can add one or more elements to the end of the array and return a new length
pop() method: You can delete the last element of the array and return the deleted element. Note: If the array is empty, the method does not perform any operations and returns undefined.
unshift() method: You can add one or more elements to the beginning of the array and return a new length
shift() method: You can delete the first element of the array and return the deleted element. Note: If the array is empty, the method does not perform any operations and returns undefined.
splice() method: add/delete items from the array, and then return the deleted item. This method will change the original array
Syntax: arrObject.splice(index,howmany,item,...,itemX)
Index parameter: Required, specify the location of adding/deleting items. Using negative numbers can specify the location from the end of the array
howmany parameter: Required, the number of items to be deleted, if set to 0, the items will not be deleted
item,...,itemX parameters: optional, new items added to the array
slice() method: You can return the selected element from the array, return the new array, and will not change the original array
Syntax: arrObject.slice(start, end)
start parameter: Required, specify the position to start selection. If it is a negative number, then select from the tail of the specified array, for example: -1 exponentially the last element of the array, -2 means the second to last element.
end parameter: optional, specifying where to end the selection. If not specified, the split array contains all elements from the beginning to the end. If it is a negative number, then the element that is calculated from the tail of the specified array
concat() method: used to concatenate two or more arrays. This method will not change the existing array and will return a new array after being connected.
Syntax: arrayObject.concat(arrayX,arrayX,......,arrayX)
arrayX parameter: Required, can make specific values or array objects.
sort() method: implements sorting arrays, and defaults to ascending order in the order of ASCII characters.
join() method: Used to put all elements in the array into a string. Elements are separated by specified delimiters. Returns a string
Syntax: join(list[,delimiter])
list parameter: Required, a one-dimensional array containing the substrings to be concatenated.
Delimiter parameter: optional. The characters used in the return string to separate the substring. If omitted, the empty character ("") will be used.
The above is a compilation of the array method notes in JS introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!