any86 / Notes

:rocket: 笔记
https://github.com/any86/Notes/issues
28 stars 9 forks source link

2个数值互相切换的最短代码 #12

Open any86 opened 5 years ago

any86 commented 5 years ago
var n1 = 1,n2=2, active=n1;
for(let i = 0;i<10;i++){
    active = n1^n2^active;
    console.log(`第${i}次`, active)
}

image