Version: v0.8.1 - Beta.  We welcome contributors & feedback.

String.getChar

getChar($index) -> string

Description

Return the single character at $index.

A negative index counts from the end of the string.

If the index is outside the bounds of the string, it will return an empty string ''.

'abcdef'.getChar(1)
//= 'a'

'abcdef'.getChar(3)
//= 'c'

'abcdef'.getChar(-1)
//= 'f'

'abcdef'.getChar(100)
//= ''

See Also