Assign value to multiple variables at once in Javascript

Assign value to multiple variables at once in Javascript

Written by Ejaaz Khan on Sep 29th, 2021 Views Report Post

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

<pre class="highlight plaintext">```  
    let [a,b,c] = [1,2,3];

    console.log(a,b,c);




Output:

[![Output](https://res.cloudinary.com/practicaldev/image/fetch/s--cuVKCvS1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3b8yxsbyhx8e3c9634r9.PNG)](https://res.cloudinary.com/practicaldev/image/fetch/s--cuVKCvS1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3b8yxsbyhx8e3c9634r9.PNG)    
My Blog:- <https://beginners-developer.blogspot.com/>    
Reference: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring\_assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment)

Comments (0)