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);

Output:

My Blog:- ht…


This content originally appeared on DEV Community and was authored by Beginner Developer

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);

Output:

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


This content originally appeared on DEV Community and was authored by Beginner Developer


Print Share Comment Cite Upload Translate Updates
APA

Beginner Developer | Sciencx (2021-08-24T16:50:52+00:00) Assign value to multiple variables at once in Javascript. Retrieved from https://www.scien.cx/2021/08/24/assign-value-to-multiple-variables-at-once-in-javascript/

MLA
" » Assign value to multiple variables at once in Javascript." Beginner Developer | Sciencx - Tuesday August 24, 2021, https://www.scien.cx/2021/08/24/assign-value-to-multiple-variables-at-once-in-javascript/
HARVARD
Beginner Developer | Sciencx Tuesday August 24, 2021 » Assign value to multiple variables at once in Javascript., viewed ,<https://www.scien.cx/2021/08/24/assign-value-to-multiple-variables-at-once-in-javascript/>
VANCOUVER
Beginner Developer | Sciencx - » Assign value to multiple variables at once in Javascript. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/08/24/assign-value-to-multiple-variables-at-once-in-javascript/
CHICAGO
" » Assign value to multiple variables at once in Javascript." Beginner Developer | Sciencx - Accessed . https://www.scien.cx/2021/08/24/assign-value-to-multiple-variables-at-once-in-javascript/
IEEE
" » Assign value to multiple variables at once in Javascript." Beginner Developer | Sciencx [Online]. Available: https://www.scien.cx/2021/08/24/assign-value-to-multiple-variables-at-once-in-javascript/. [Accessed: ]
rf:citation
» Assign value to multiple variables at once in Javascript | Beginner Developer | Sciencx | https://www.scien.cx/2021/08/24/assign-value-to-multiple-variables-at-once-in-javascript/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.