firstCodePoint
Return the first
n
Unicode code points of a string.
Usage
var firstCodePoint = require( '@stdlib/string/base/first-code-point' );
firstCodePoint( str, n )
Returns the first n
Unicode code points of a string.
var out = firstCodePoint( 'last man standing', 1 );
// returns 'l'
out = firstCodePoint( 'Hidden Treasures', 1 );
// returns 'H'
out = firstCodePoint( 'foo bar', 5 );
// returns 'foo b'
out = firstCodePoint( 'foo bar', 10 );
// returns 'foo bar'
Examples
var firstCodePoint = require( '@stdlib/string/base/first-code-point' );
var str = firstCodePoint( 'presidential election', 1 );
// returns 'p'
str = firstCodePoint( 'JavaScript', 1 );
// returns 'J'
str = firstCodePoint( 'The Last of the Mohicans', 5 );
// returns 'The L'
str = firstCodePoint( 'अनुच्छेद', 1 );
// returns 'अ'