JS的递增/递减运算符和带操作的赋值运算符的等价式_javascript技巧
程序员文章站
2023-12-25 11:44:03
...
1.递增/递减运算符等价式
a=b++; a=b;b=b+1;
a=++b; b=b+1;b=b;
a=b--; a=b;b=b-1;
a=--b; b=b-1;b=b;
所以,a=5;b=6;var3=a++*--b,结果为25
2.带操作的赋值运算符等价式
a*=b; a=a*b;
a/=b; a=a/b;
a+=b; a=a+b;
a-=b; a=a-b;
a%=b; a=a%b;
a&=b; a=a&b; //从&=开始,下边都是逐位运算符
a|=b; a=a|b;
a^=b; a=a^b;
a>>=b; a=a>>b;
a
a=b++; a=b;b=b+1;
a=++b; b=b+1;b=b;
a=b--; a=b;b=b-1;
a=--b; b=b-1;b=b;
所以,a=5;b=6;var3=a++*--b,结果为25
2.带操作的赋值运算符等价式
a*=b; a=a*b;
a/=b; a=a/b;
a+=b; a=a+b;
a-=b; a=a-b;
a%=b; a=a%b;
a&=b; a=a&b; //从&=开始,下边都是逐位运算符
a|=b; a=a|b;
a^=b; a=a^b;
a>>=b; a=a>>b;
a