var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("strawberry")
Created page with "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 ite..." |
No edit summary |
||
(7 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= | count=Push(fruits,"Strawberry") | ||
</ | </syntaxhighlight> | ||
</tabber> | |||
< | |||
== Output == | |||
The new value of fruits will be: | |||
The | |||
<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]] |
Push(array, 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.
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("strawberry")
fruits = ["Banana", "Orange", "Apple", "Mango"]
count=Push(fruits,"Strawberry")
The new value of fruits will be:
Banana,Orange,Apple,Mango,Strawberry