Push: Difference between revisions

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


At position 2, remove 2 items:
<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 result of fruits will be:
</tabber>
<pre>
 
Banana,Orange,Apple,Mango,Strawberry
== Output ==
</pre>


== Example (JavaScript) ==
The new value of fruits will be:
At position 2, remove 2 items:
<pre>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("strawberry")
</pre>
The result 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

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