How to swap two numbers without using a temporary variable ? | Javascript code to swap using XOR ; Code to swap ' x ' ( 1010 ) and ' y ' ( 0101 ) x now becomes 15 ( 1111 ) ; y becomes 10 ( 1010 ) ; x becomes 5 ( 0101 )
let x = 10 , y = 5 ; x = x ^ y ; y = x ^ y ; x = x ^ y ; document . write ( " " + x + " " + y ) ;