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.
When you access any element of the DOM, it is usual to save it in a variable. This is something that at first might seem very simple, but if you…
In this tutorial we are going to see how you can change the order of the elements of an array so that they are inverted. You could use a loop…
In case you have two divs of different sizes you may sometimes want to scroll both at the same time but at different speeds depending on their size. For example,…