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 AND DEVELOPMENT.
Symbols are a new primitive value introduced by ES6. Their purpose is to provide us unique identifiers. In this article, we tell you how they work, in which way they…
When I started browsing different and original websites to learn from them, one of the first things that caught my attention was that some of them had their own cursors,…
In this tutorial we will see how to install and use both Node.js and the npm package manager. In addition, we will also create a small sample application. If you…