DEV Community

Cover image for Assign value to multiple variables at once in Javascript
Beginner Developer
Beginner Developer

Posted on • Originally published at beginners-developer.blogspot.com

5 2

Assign value to multiple variables at once in Javascript

The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.

    let [a,b,c] = [1,2,3];

    console.log(a,b,c);
Enter fullscreen mode Exit fullscreen mode

Output:

Output
My Blog:- https://beginners-developer.blogspot.com/
Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

Oldest comments (0)

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay