简单且逼格高的运算符
var a = 12; console.log(-a); //输出 -12 - -> 取反 var b = a++; console.log(b); //输出 12 - -> 先赋值b,a再++ b = ++a; console.log(b); //输出 14 - -> ++a赋值b,a先++后赋值
var a = 1; var b = 2; a += b; //相当于 a = a + b console.log(a); //输出 3
a += b + 3; //相当于 a = a + b + 3 console.log(a); //输出 8
a -= b; //相当于 a = a - b console.log(a); //输出 6
a *= b; //相当于 a = a * b console.log(a); //输出 12
a /= b; //相当于 a = a / b console.log(a); //输出 6
a %= b; //相当于 a = a % b console.log(a); //输出 0
三目运算符
var score = 80; var result = score > 60 ? “及格”:“不及格”; console.log(result); //输出 及格