Slice UTF-16 code units from a string.
var slice = require( '@stdlib/string/base/slice' );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).
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'