Array.push
Array.push
Function
Appends one or more elements to the end of the array.
Syntax
array.push(value1, value2, ...)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| valueN | Any | No | None | The element to append. |
Return value
| Type | Description |
|---|---|
| Array | Returns the original array object. |
Example
items = [1, 2] result = items.push(3) // Output: [1,2,3] print result
Notes
- This method will modify the original array.