L' +operatore puo' anche essere utilizzato per aggiungere (concatenare) stringhe.
Esempio var txt1 = "John"; var txt2 = "Doe"; var txt3 = txt1 + " " + txt2; Il risultato di txt3 sara': John Doe ***************************************************** <!DOCTYPE html> <html> <body> <h2>JavaScript Operators</h2> <p>The + operator concatenates (adds) strings.</p> <p id="demo"></p> <script> var txt1 = "John"; var txt2 = "Doe"; document.getElementById("demo").innerHTML = txt1 + " " + txt2; </script> </body> </html> |