unshift

Summary

Adds the specified element to the beginning of the array.

Signatures

Click on a signature to select it and view its documentation.

Usage

public int unshift(T elements)

Returns

The size of the array after the new element was added.

Parameters

elements

The element to add to the top of the array.

Description

Adds the specified element to the beginning of the array and returns the size of the modified array.

This method mutates the array.

Examples

Basic Usage
1
2
3
4
5
6
import System;
 
int[] arr = [ 2, 3, 4 ];
Console.log(arr.first()); // 2
arr.unshift(1);
Console.log(arr.first()); // 1

Share

HTML | BBCode | Direct Link