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

JavascriptWeb DevelopmentFront End Technology

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”
raja
Published on 18-Jan-2018 08:31:03
Advertisements