JavaScript's String.prototype.charAt()

This is just an object’s method that returns a single UTF-16 code unit to the specified offset of the string.

Code view

  1. const text = ‘I love my country!’;
  2. const find = 5;
  3. console.log(`The character at index ${find} is ${text.chart(find)}`);
    // expected output: “The character at index 5 is e”

Syntax

charAt(index)

Parameters

index

An integer between 0 and 1-less-than the length of the string.

Description

From left to right. The index starts the first character is 0. This string is stringName.length-1, If the starts you supply is out of the range, JavaScript returns an empty string.

--

--

Sayful Islam Shakib
0 Followers

Web Developer, Professional Graphics Designer & google certified UX/UI designer.