Javascript examples for Data Type:var
Start the statement with var and separate the variables by comma:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {// ww w . j av a 2s . co m var lastName = "Bond", age = 30, job = "carpenter"; document.getElementById("demo").innerHTML = "Name: " + lastName + ". Age: " + age + ". Work: " + job; } </script> </body> </html>