Multiple Declarations in One Statement
You'll learn: How to declare several variables at once on a single line using var, let, or const.
Instead of writing separate declaration statements for each variable, JavaScript lets you declare multiple variables in one go by separating them with commas. This works with var, let, and const.
The Syntax
Here's how it looks:
let firstName, lastName, age;
This declares three variables in one statement—they all start as undefined until you assign values.
You can also initialize some or all of them immediately:
let firstName = "Sarah", lastName = "Chen", age = 28;
The same pattern works with const (though you must initialize):
const pi = 3.14159, gravity = 9.8, speedOfLight = 299792458;
When to Use This Style
Multiple declarations save vertical space, which can be tempting. However, they often hurt readability—especially when initializing values. Most developers prefer separate lines:
let firstName = "Sarah";
let lastName = "Chen";
let age = 28;
This makes each variable easier to spot, modify, and understand at a glance.
Think of It Like a Shopping List
You could write "milk, bread, eggs" on one line, but listing each item on its own line makes it easier to check off and scan quickly. Code works the same way.
Key Takeaway: You can declare multiple variables in one statement by separating them with commas, but separate declarations usually improve readability and are preferred in modern JavaScript.