4TH

SWAPPING VALUE

4TH
Apr 2nd, 2026
4
0
Never
Not a member of GistPad yet? Sign Up, it unlocks many cool features!
JavaScript 1.34 KB | Source Code | 0 0
  1. let a = 10;
  2. let b = 20;
  3.  
  4. console.log("Before swapping: a =", a, "b =", b);
  5. [a, b] = [b, a]; // Swapping happens here
  6. console.log("After swapping: a =", a, "b =", b);
RAW Paste Data Copied