Files
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

543 B

title
title
Use Destructuring Assignment to Assign Variables from Arrays

Use Destructuring Assignment to Assign Variables from Arrays


Hints

Hint # 1

We have to take some precaution in this case.

  1. No need of const [b,a] as it will keep the effect of assignment local.

  2. const [b,a] = [a,b] will result in the value of a,b as undefined(simple assignment rule left to right).


Solutions

Solution 1 (Click to Show/Hide)
let a = 8,
  b = 6;
[a, b] = [b, a];