Push: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
No edit summary
 
(2 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 (Basic) ==
== Example ==


Add an item to the end:
<tabber>
<pre>
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")
</pre>
</syntaxhighlight>
The new value of fruits will be:
</tabber>
<pre>
 
Banana,Orange,Apple,Mango,Strawberry
== Output ==
</pre>


== Example (JavaScript) ==
Add an item to the end.
<pre>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("strawberry")
</pre>
The new value of fruits will be:
The new value of fruits will be:
<pre>
<pre>
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

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("strawberry")

fruits = ["Banana", "Orange", "Apple", "Mango"]
count=Push(fruits,"Strawberry")

Output

The new value of fruits will be:

Banana,Orange,Apple,Mango,Strawberry

Related Items

Array, Dim, LBound, Splice, ReDim