swapping with temporary variable in javascript and using it angular code example Example: swap two variables javascript var a = 1, b = 2; b = [a, a = b][0];