Javascript examples for Data Type:var
Create two variables. Assign the number 5 to x, and 6 to y. Then display the result of x + y:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {// www . j a v a 2 s. c o m var x = 5; var y = 6; document.getElementById("demo").innerHTML = x + y; } </script> </body> </html>