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
Get largest number from each sub-arrays
How to get selected text from a select box using jQuery?
How to current URL, HOST and URL attributes using JavaScript or jQuery?
jQuery example of scroll to top
JavaScript check if first string contains all characters of second string
How can I redirect the user from one page to another using jQuery or pure JavaScript?