@stdlib/string-base-slice
v0.1.1
Published
Slice UTF-16 code units from a string.
Readme
slice
Slice UTF-16 code units from a string.
Installation
npm install @stdlib/string-base-sliceUsage
var slice = require( '@stdlib/string-base-slice' );slice( str, start, end )
Slices UTF-16 code units from a string.
var out = slice( 'last man standing', 1, 17 );
// returns 'ast man standing'
out = slice( 'Hidden Treasures', 0, 6 );
// returns 'Hidden'
out = slice( 'foo bar', 2, 7 );
// returns 'o bar'
out = slice( 'foo bar', -1, 7 );
// returns 'r'The function accepts the following arguments:
- str: input string.
- start: slice start index (inclusive).
- end: slice end index (exclusive).
Examples
var slice = require( '@stdlib/string-base-slice' );
var str = slice( 'presidential election', 1, 21 );
// returns 'residential election'
str = slice( 'JavaScript', 4, 10 );
// returns 'Script'
str = slice( 'The Last of the Mohicans', 5, 24 );
// returns 'ast of the Mohicans'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.
