UNPKG

voca

Version:

The ultimate JavaScript string library

31 lines (26 loc) 743 B
'use strict'; require('./internal/is_nil.js'); require('./is_string.js'); var coerce_to_string = require('./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 = coerce_to_string.coerceToString(subject); return subjectString.charAt(position); } module.exports = charAt;