One liner for swapping vars in Javascript

Snippet

You can swap two variables in javascript like every other language: by using an intermediate variable. OR! You can have a one liner.

Love me those one liners!

b = [a, a = b][0];

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.