算数运算符包括+ - * / %(加、减、乘、除、取模)
加减乘除我们都不陌生,理解取模是我们要做到的,取模——返回剩余的余数值
记住 表达式是由数字、运算符、变量等共同组成的式子
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script>
console.log(1 + 1); // 2
console.log(1 - 1); // 0
console.log(1 * 1); // 1
console.log(1 / 1); // 1
// 1. % 取余 (取模)
console.log(4 % 2); // 0
console.log(5 % 3); // 2
console.log(3 % 5); // 3
// 2. 浮点数 算数运算里面会有问题
console.log(0.1 + 0.2); // 0.30000000000000004
console.log(0.07 * 100); // 7.000000000000001
// 3. 我们不能直接拿着浮点数来进行相比较 是否相等(0.1+0.2 的值即为 0.1 和 0.2 对应的二进制数值的相加)
var num = 0.1 + 0.2;
console.log(num == 0.3); // false
// 表达式: 是由数字、运算符、变量等共同组成的式子 ,我们叫做表达式
console.log(1 + 1); // 2 就是返回值
// 1 + 1 = 2
// 右边表达式计算完毕把返回值给左边
var num = 1 + 1;
</script>
</head>
<body>
</body>
</html>