charCodeAt method can be used with both standard strings defined with single or double quotes and String objects or literal templates.
charCodeAt(1) // 97
If there is no character in the position we pass as parameter to the method, the returned value will be NaN. This case will occur when we want to obtain the code of the character that is in a position whose value is equal to or greater than the length of the string. The NaN value means Not a Number, returned when the result obtained is not a numeric value.
charCodeAt(20) // NaN
charCodeAt method works in exactly the same way with String objects, as you can see in the following example
charCodeAt(1); // 97
In addition, you can use the toString method with the result obtained by the
charCodeAt method to convert the Unicode code into a character.
In case you want to get the representation of special characters whose representation consists of two 16-bit units, you have to use the
charCodeAt method twice, with two consecutive indices. Alternatively, you can also use the codePointAt method. Alternatively, you can also use the codePointAt method. For more information about this method, see how to use the
Licenciada en Bellas Artes y programadora por pasión. Cuando tengo un rato retoco fotos, edito vídeos y diseño cosas. El resto del tiempo escribo en MA-NO WEB DESIGN END DEVELOPMENT.
After having published several articles about how to manipulate arrays and dates, today I will publish a post that some of you will find too basic and others will find…
We often use webcams to broadcast video in real time via our computer. This broadcast can be viewed, saved and even shared via the Internet. As a rule, we need…
Working with React, - and before the release of Hooks in version 16.8 - there was always the possibility to create components in three different ways based on a number of…