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
How to scroll page to 1000px from top on page load using jQuery?
jQuery check if an element is visible or hidden
jQuery move multi select values from one to another multi select list
JavaScript convert string variable in boolean using Regex
Highlight and get the details of table row on click using JavaScript
Using jQuery delete table row on click