How to declare multiple variables in one statement in Javascript?

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