How to Declare Multiple Variables in JavaScript in One Line?

Estimated read time 1 min read

In JavaScript, you can declare multiple variables in one line by separating the variables with commas:

var name = "John", age = 30, isStudent = false;

It’s important to note that each variable declared this way will have the same type and scope. If you want to declare variables with different types or scopes, it’s better to declare each variable on a separate line.

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply