ToString restituisce un numero come stringa





'Il metodo toString ()

'Il toString()metodo restituisce un numero come stringa.


'Tutti i metodi numerici possono essere utilizzati su qualsiasi tipo di numeri (letterali, variabili o espressioni):


'Esempio

'var x = 123;

'x.toString(); // returns 123 from variable x

'(123).toString(); // returns 123 from literal 123

'(100 + 23).toString(); // returns 123 from expression 100 + 23


https://www.w3schools.com/js/tryit.asp?filename=tryjs_number_tostring

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Number Methods</h2>

<p>The toString() method converts a number to a string.</p>

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

<script>
var x = 123;
document.getElementById("demo").innerHTML =
x.toString() + "<br>" +
(123).toString() + "<br>" +
(100 + 23).toString();
</script>

</body>
</html>










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