javascript
Swapping two values using Destructuring in Javascript
You can easily swap two values using Destructuring in Javascript
let a = 5;
let b = 8;
[a, b] = [b, a]
console.log([a, b])
Live Demo
Was this helpful?
Similar Posts
- Javascript ES6 Destructuring
- Assign items of arrays to multiple variable when creating it (Array Destructuring) Javascript(ES6)
- Join two arrays and remove duplicate elements using Javascript
- Javascript program to swap two numbers without using temporary variable
- Combine or merge two or multiple arrays into single array in Javascript
- Javascript to get the number of days between two dates
- Get the sum of array values using Javascript - Solved