@stdlib/array-base-first
v0.2.3
Published
Return the first element of an array-like object.
Downloads
134
Readme
first
Return the first element of an array-like object.
Installation
npm install @stdlib/array-base-firstUsage
var first = require( '@stdlib/array-base-first' );first( x )
Returns the first element of an array-like object.
var x = [ 1, 2, 3 ];
var out = first( x );
// returns 1Examples
var Complex64Array = require( '@stdlib/array-complex64' );
var first = require( '@stdlib/array-base-first' );
// Create a complex number array:
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
// Return the first element:
var out = first( arr );
// returns <Complex64>[ 1.0, 2.0 ]
console.log( '%s', out.toString() );
// => '1 + 2i'Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
