Push: Difference between revisions
Jump to navigation
Jump to search
Line 23: | Line 23: | ||
fruits.push("strawberry") | fruits.push("strawberry") | ||
</pre> | </pre> | ||
The | The new value of fruits will be: | ||
<pre> | <pre> | ||
Banana,Orange,Apple,Mango,Strawberry | Banana,Orange,Apple,Mango,Strawberry |
Revision as of 12:28, 12 May 2014
Push(array, item)
Description
The Push() method adds an item to end of an array. This function changes the original array. It returns the number of items in the array after adding the new item.
Example (Basic)
Add an item to the end:
fruits = ["Banana", "Orange", "Apple", "Mango"] count=Push(fruits,"Strawberry")
The new value of fruits will be:
Banana,Orange,Apple,Mango,Strawberry
Example (JavaScript)
Add an item to the end.
var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.push("strawberry")
The new value of fruits will be:
Banana,Orange,Apple,Mango,Strawberry