@stdlib/string-base-last
v0.1.1
Published
Return the last UTF-16 code unit of a string.
Downloads
17
Readme
last
Return the last
n
UTF-16 code units of a string.
Installation
npm install @stdlib/string-base-last
Usage
var last = require( '@stdlib/string-base-last' );
last( str, n )
Returns the last n
UTF-16 code units of a string.
var s = last( 'hello world', 1 );
// returns 'd'
s = last( 'this is stdlib', 1 );
// returns 'b'
s = last( 'foo', 2 );
// returns 'oo'
s = last( 'foo bar', 10 );
// returns 'foo bar'
Examples
var last = require( '@stdlib/string-base-last' );
var str = last( 'elections', 1 );
// returns 's'
str = last( 'JavaScript', 1 );
// returns 't'
str = last( 'good night', 5 );
// returns 'night'
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.