Sometimes, we want to define multiple variables on a single line with JavaScript.
In this article, we’ll look at how to define multiple variables on a single line with JavaScript.
How to define multiple variables on a single line with JavaScript?
To define multiple variables on a single line with JavaScript, we can use the array destructuring syntax.
For instance, we write
const [a, b, c, d] = [0, 1, 2, 3];
to assign a to 0, b to 1, cto 2, andd` to 3 with the array destructuring syntax.
Conclusion
To define multiple variables on a single line with JavaScript, we can use the array destructuring syntax.