Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

first

Return the first element of an array-like object.

Usage

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 1

Examples

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'