Great post. Cool trick! Thanks for introducing me to codedrops.tech!
Serious question though - why would you avoid using the temporary variable?
let x = 5, y = 3, temp = null; temp = x; x = y; y = temp; console.log(x,y); // 3 5
Just about the same number of characters, more clear what is being done.
This is a very old school trick that is still useful on contexts like embedded development where you have very limited memory available.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great post. Cool trick! Thanks for introducing me to codedrops.tech!
Serious question though - why would you avoid using the temporary variable?
Just about the same number of characters, more clear what is being done.
This is a very old school trick that is still useful on contexts like embedded development where you have very limited memory available.