@stdlib/array-base-last
v0.2.2
Published
Return the last element of an array-like object.
Downloads
4
Readme
last
Return the last element of an array-like object.
Installation
npm install @stdlib/array-base-last
Usage
var last = require( '@stdlib/array-base-last' );
last( x )
Returns the last element of an array-like object.
var x = [ 1, 2, 3 ];
var out = last( x );
// returns 3
Examples
var Complex64Array = require( '@stdlib/array-complex64' );
var realf = require( '@stdlib/complex-float32-real' );
var imagf = require( '@stdlib/complex-float32-imag' );
var last = require( '@stdlib/array-base-last' );
// Create a complex number array:
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
// Return the last element:
var out = last( arr );
// returns <Complex64>
var re = realf( out );
// returns 5.0
var im = imagf( out );
// returns 6.0
console.log( '%d + %di', re, im );
// => '5 + 6i'
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-2024. The Stdlib Authors.