Swap three variables without using temporary variable | javascript program to swap three variables without using temporary variable . ; Assign c ' s ▁ value ▁ to ▁ a , ▁ a ' s value to b and b 's value to c. ; Store XOR of all in a ; After this , b has value of a ; After this , c has value of b ; After this , a has value of c ; Driver Code ; Calling Function
var a , b , c ; function swapThree ( ) { a = a ^ b ^ c ; b = a ^ b ^ c ; c = a ^ b ^ c ; a = a ^ b ^ c ; } a = 10 ; b = 20 ; c = 30 ; document . write ( " " + a + " " + b + " " + c ) ; swapThree ( ) ; document . write ( " " ) document . write ( " " + a + " " + b + " " + c ) ;