Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/unshift/docs/types/index.d"

Index

Functions

Functions

Export assignment unshift

  • Adds one or more elements to the beginning of a collection.

    Notes

    • If the input collection is a typed array, the output value does not equal the input reference and the underlying ArrayBuffer may not be the same as the ArrayBuffer belonging to the input view.
    • For purposes of generality, always treat the output collection as distinct from the input collection.

    Parameters

    • collection: Collection

      collection

    • Rest ...items: Array<any>

      items to add

    Returns Collection

    updated collection

    Example

    var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];
    
    arr = unshift( arr, 6.0, 7.0 );
    // returns [ 6.0, 7.0, 1.0, 2.0, 3.0, 4.0, 5.0 ]

    Example

    var Float64Array = require( `@stdlib/array/float64` );
    
    var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
    // returns <Float64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
    
    arr = unshift( arr, 6.0, 7.0 );
    // returns <Float64Array>[ 6.0, 7.0, 1.0, 2.0, 3.0, 4.0, 5.0 ]