voca
Version:
The ultimate JavaScript string library
29 lines (25 loc) • 709 B
JavaScript
import './internal/is_nil.js';
import './is_string.js';
import { c as coerceToString } from './internal/coerce_to_string.js';
/**
* Access a character from `subject` at specified `position`.
*
* @function charAt
* @static
* @since 1.0.0
* @memberOf Chop
* @param {string} [subject=''] The string to extract from.
* @param {numbers} position The position to get the character.
* @return {string} Returns the character at specified position.
* @example
* v.charAt('helicopter', 0);
* // => 'h'
*
* v.charAt('helicopter', 1);
* // => 'e'
*/
function charAt(subject, position) {
var subjectString = coerceToString(subject);
return subjectString.charAt(position);
}
export default charAt;