Unshift
Description
The Unshift()
method adds one or more elements to the beginning of an array and returns the new length of the array.
Syntax
expression.Unshift([Args1[, Args2[, …[, ArgsN]]]])
Parameters
- Name
Args
- Type
- ParamArray
Variant
- Necessity
- Optional
- Description
- The element(s) to be added to the beginning of the array
Returns
- Type
Long
- Description
- The new length of the array.
Example
Public Sub UnshiftExample()
Dim result() As Variant
Dim MyArray As BetterArray
Set MyArray = New BetterArray
MyArray.Push "Banana", "Orange", "Apple", "Mango"
MyArray.Unshift "Lemon", "Pineapple"
result = MyArray.Items
' expected output:
' result is an array containing: "Lemon", "Pineapple","Banana", "Orange", "Apple", "Mango"
End Sub