charCodeAt () Estrazione di carattere ASCII stringa




Il metodo charCodeAt ()
Il charCodeAt()metodo restituisce l'unicode del carattere in un indice specificato in una stringa:

Il metodo restituisce un codice UTF-16 (un numero intero compreso tra 0 e 65535).

Esempio
var str = "HELLO WORLD";

str.charCodeAt(0); // returns 72
*********************************************************************
Accesso alla proprieta'
ECMAScript 5 (2009) consente l'accesso alle proprieta' [] sulle stringhe:

Esempio
var str = "HELLO WORLD";
str[0]; // returns H

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript String Methods</h2>

<p>ECMAScript 5 allows property access on strings:</p>

<p id="demo"></p>

<script>
var str = "HELLO WORLD";
document.getElementById("demo").innerHTML = str[0];
</script>
</body>
</html>










( charcodeatestrazionedicarattereasciistringa.html )- by Paolo Puglisi - Modifica del 17/12/2023