Javascript ES6 - Swap Variables

let a = 0, b = 1; console.log(a, b); // 0 1 [b, a] = [a, b]; console.log(a, b); // 1 0
How to swap variables in one line.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.