This JavaScript tutorial explains how to use the string approach referred to as codePointAt() with syntax and examples.
Description
In JavaScript, codePointAt() is a string technique that is used to retrieve the Unicode code factor (that may also no longer be representable in a single UTF-16 code unit) for a persona at a precise position in a string. Because the codePointAt() technique is a technique of the String object, it have to be invoked via a precise instance of the String class.
Syntax
In JavaScript, the syntax for the codePointAt() approach is:
string.codePointAt([position]);
Parameters or Arguments
position Optional. It is the position of the personality in string that you desire to retrieve the Unicode code points for. The first role in the string is zero If this parameter is not provided, the codePointAt() approach will use zero as the default.
Returns
The codePointAt() technique returns a Unicode code point for a persona at a specific role in a string.
If the position is out of bounds and there is no persona at the given position, the codePointAt() approach will return undefined.
Note
You can also use the charCodeAt() method if the Unicode price of the character is representable in a single UTF-16 code unit. The codePointAt() approach does not trade the cost of the unique string.
Example
Let’s take a appear at an example of how to use the codePointAt() method in JavaScript.
For example:
Leave a Review