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: 13-Sep-2019

122 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements