var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("strawberry")
Push: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
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. | 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 | == Example == | ||
<tabber> | |||
< | JavaScript= | ||
<syntaxhighlight lang="JavaScript"> | |||
var fruits = ["Banana", "Orange", "Apple", "Mango"]; | |||
fruits.push("strawberry") | |||
</syntaxhighlight> | |||
|-| | |||
BASIC= | |||
<syntaxhighlight lang="vb.net"> | |||
fruits = ["Banana", "Orange", "Apple", "Mango"] | fruits = ["Banana", "Orange", "Apple", "Mango"] | ||
count=Push(fruits,"Strawberry") | count=Push(fruits,"Strawberry") | ||
</ | </syntaxhighlight> | ||
</tabber> | |||
== Output == | |||
The new value of fruits will be: | The new value of fruits will be: | ||
<pre> | <pre> | ||
Banana,Orange,Apple,Mango,Strawberry | Banana,Orange,Apple,Mango,Strawberry | ||
Line 35: | Line 35: | ||
[[Category:Variable Handling]] | [[Category:Variable Handling]] | ||
[[Category:BASIC Functions]] |
Latest revision as of 23:02, 24 July 2019
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
fruits = ["Banana", "Orange", "Apple", "Mango"]
count=Push(fruits,"Strawberry")
Output
The new value of fruits will be:
Banana,Orange,Apple,Mango,Strawberry