var a = 123;
var result = typeof a;
console.log(typeof result, "result = " + result);
result = a + 1;
console.log(typeof result, "result = " + result);
result = 456 + 789;
console.log("result = " + result);
result = true + 1;
console.log(typeof result, "result = " + result);
result = true + false;
console.log(typeof result, "result = " + result);
result = 2 + null;
console.log(typeof result, "result = " + result);
result = 2 + NaN;
console.log(typeof result, "result = " + result);
result = "你好" + "大帅哥";
console.log(typeof result, "result = " + result);
var str = "锄禾日当午," +
"汗滴禾下土," +
"谁知盘中餐," +
"粒粒皆辛苦";
console.log("result = " + result);
result = 123 + "1";
console.log(typeof result, "result = " + result);
result = true + "hello";
console.log(typeof result, "result = " + result);
var c = 123;
c = c + "";
console.log(typeof result, "result = " + result);
result = 1 + 2 + "3"; // 33
console.log(typeof result, "result = " + result);
result = "1" + 2 + 3; // 123
console.log(typeof result, "result = " + result);
result = 100 - 5;
console.log("result = " + result);
result = 100 - true;
console.log(typeof result, "result = " + result);
result = 100 - "1";
console.log(typeof result, "result = " + result);
result = 2 * 2;
console.log(typeof result, "result = " + result);
result = 2 * "8";
console.log(typeof result, "result = " + result);
result = 2 * undefined;
console.log(typeof result, "result = " + result);
result = 2 * null;
console.log(typeof result, "result = " + result);
result = 4 / 2;
console.log(typeof result, "result = " + result);
result = 3 / 2;
console.log(typeof result, "result = " + result);
var d = "123";
d = d - 0;
console.log(typeof result, "result = " + result);
result = 9 % 3;
result = 9 % 4;
result = 9 % 5;
console.log("result = " + result);

运算符也叫操作符
比如:typeof 就是运算符,可以用来获得一个值的类型
number string boolean undefined object
var a = 123;
var result = typeof a;
console.log(typeof result);
任何值和 NaN 做运算都得 NaN
var result = 2 + NaN;
console.log(typeof result, "result = " + result);
var result = a + 1;
console.log(typeof result, "result = " + result);
result = 456 + 789;
console.log("result = " + result);
result = true + 1;
console.log(typeof result, "result = " + result);
result = true + false;
console.log(typeof result, "result = " + result);
result = 2 + null;
console.log(typeof result, "result = " + result);
result = 2 + NaN;
console.log(typeof result, "result = " + result);
result = "你好" + "大帅哥";
console.log(typeof result, "result = " + result);
var str = "锄禾日当午," + "汗滴禾下土," + "谁知盘中餐," + "粒粒皆辛苦";
console.log("result = " + result);
result = 123 + "1";
console.log(typeof result, "result = " + result);
result = true + "hello";
console.log(typeof result, "result = " + result);
var c = 123;
c = c + "";
console.log(typeof c, "c = " + c);
result = 1 + 2 + "3"; // 33
console.log(typeof result, "result = " + result);
result = "1" + 2 + 3; // 123
console.log(typeof result, "result = " + result);
可以对两个值进行减法运算,并将结果返回
var result = 100 - 5;
console.log("result = " + result);
result = 100 - true;
console.log(typeof result, "result = " + result);
result = 100 - "1";
console.log(typeof result, "result = " + result);
可以对两个值进行乘法运算
var result = 2 * 2;
console.log("result = " + result);
result = 2 * "8";
console.log(typeof result, "result = " + result);
result = 2 * undefined;
console.log(typeof result, "result = " + result);
result = 2 * null;
console.log(typeof result, "result = " + result);
可以对两个值进行除法运算
var result = 4 / 2;
console.log("result = " + result);
result = 3 / 2;
console.log("result = " + result);
% 取模运算(取余数)
var result = 9 % 3;
console.log("result = " + result);
result = 9 % 4;
console.log("result = " + result);
result = 9 % 5;
console.log(typeof result, "result = " + result);
任何值和字符串相加都会转换为字符串,并做拼串操作
var c = 123;
c = c + "";
console.log(typeof c, "c = " + c);
c = null;
c = c + "";
console.log(typeof c, "c = " + c);
c = 1 + 2 + "3"; // 33
console.log(typeof c, "c = " + c);
c = "1" + 2 + 3; // 123
console.log(typeof c, "c = " + c);
var d = "123";
d = d - 0;
console.log(typeof d, "d = " + d);