Start the statement with var and separate the variables by comma:
<!DOCTYPE html>
<html>
<body>
<p id="test"></p>
<script>
var name = "John Doe", userName = "user58", age = 23;
document.getElementById("test").innerHTML = name + " " + userName + " " + age;
</script>
</body>
</html>
Variables declaration can span into multiple lines also:
<!DOCTYPE html>
<html>
<body>
<p id="test"></p>
<script>
var name = "John Doe",
userName = "user58",
age = 23;
document.getElementById("test").innerHTML = name + " " + userName + " " + age;
</script>
</body>
</html>
Most Helpful This Week
Highlight and get the details of table row on click using JavaScript
How can I redirect the user from one page to another using jQuery or pure JavaScript?
How to scroll page to 1000px from top on page load using jQuery?
jQuery move multi select values from one to another multi select list
How to current URL, HOST and URL attributes using JavaScript or jQuery?
How to change the height of Textarea on click?