英[pʊʃ] 美[pʊʃ]
vt.& vi. Push, push
vt. Press; push, increase; exert pressure on, force; persuade
n. Push, determination; large-scale offensive; determined pursuit
vi. Push; increase; strive for
Third person singular: pushes Present participle: pushing Past tense: pushed past Participle: pushed
javascript push() method syntax
How to use push() method?
push() method can be used to add one or more elements to the end of the array and return the new length. The push() method can add its parameters to the end of arrayObject in sequence. Modify arrayObject directly instead of creating a new array.
Function: Add one or more elements to the end of the array and return the new length.
Syntax: arrayObject.push(newelement1,newelement2,....,newelementX)
Parameters: newelement1 Required. The first element to be added to the array. newelement2 Optional. The second element to be added to the array. newelementX Optional. Multiple elements can be added.
Return: The new length after adding the specified value to the array.
Description: push() method can add its parameters to the end of arrayObject in sequence. It directly modifies the arrayObject instead of creating a new array. The push() method and pop() method use the first-in-last-pop function provided by the array.
Note: This method will change the length of the array. To add one or more elements to the beginning of an array, use the unshift() method.
javascript push() method example
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script type="text/javascript"> var arr = new Array(3) arr[0] = "George" arr[1] = "John" arr[2] = "Thomas" document.write(arr + "<br />") document.write(arr.push("James") + "<br />") document.write(arr) </script> </body> </html>
Run instance »
Click the "Run instance" button to view the online instance