Syntax error What is the best way of declaring multiple Variables in JavaScript?

What is the best way of declaring multiple Variables in JavaScript?



Definitely, the following way of declaring multiple variables is more efficient:

var variable1 = 5;
var variable2 = 3.6;
var variable3 = “Amit”;

Suppose you need to add, remove, or update a variable, then you can easily do it.
But with the following method, you need to do more changes. For example, on removing a variable, you need to remove the semi-colon. If it’s the first, then you need to add var to the second variable.

var variable1 = 5,
variable2 = 3.6,
variable3 = “Amit”
Updated on: 2019-09-13T07:37:26+05:30

220 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements