lastCodePoint

Return the last n Unicode code points of a string.

Usage

var lastCodePoint = require( '@stdlib/string/base/last-code-point' );

lastCodePoint( str, n )

Returns the last n Unicode code points of a string.

var s = lastCodePoint( 'JavaScript', 1 );
// returns 't'

s = lastCodePoint( 'Hello World', 5 );
// returns 'World'

s = lastCodePoint( 'Good Evening', 9 );
// returns 'd Evening'

s = lastCodePoint( 'foo bar', 10 );
// returns 'foo bar'

Examples

var lastCodePoint = require( '@stdlib/string/base/last-code-point' );

var str = lastCodePoint( 'Hello World', 1 );
// returns 'd'

str = lastCodePoint( 'JavaScript', 6 );
// returns 'Script'

str = lastCodePoint( 'ASCII', 2 );
// returns 'II'

str = lastCodePoint( 'index', 10 );
// returns 'index'

str = lastCodePoint( 'अनुच्छेद', 1 );
// returns 'द'

str = lastCodePoint( '六书/六書', 3 );
// returns '/六書'
Did you find this page helpful?