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 join string with number in JavaScript?
JavaScript sort multi dimensional array on specific columns
Using jQuery delete table row on click
Highlight and get the details of table row on click using JavaScript
How to build simple tabs with jQuery?
How to change text after click event using JavaScript?