Skip to content

Instantly share code, notes, and snippets.

@langjt
Last active July 3, 2018 09:54
Show Gist options
  • Save langjt/96841a14805418ef68fc to your computer and use it in GitHub Desktop.
Save langjt/96841a14805418ef68fc to your computer and use it in GitHub Desktop.
/* a,b两个变量,不用第三个变量来交换两个变量的值 */
// a,b为数字
var a = 1,
b = 2;
a = a + b;
b = a - b;
a = a - b;
// a,b为字符串或其他类型
var a = 'a';
b = 'b';
a = [a, b];
b = a[0];
a = a[1];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment