当前位置:网站首页>算数表达式
算数表达式
2022-04-23 05:53:00 【KK要继续努力】
算数表达式
算数运算符
- +:两边操作符都是数字才相加,其余情况都是连字符
-
-
- /
- %
隐式类型转换
如果参与数学运算的某操作数不是数字类型,会自动将此操作数转为数字类型(本质是在内部调用Number函数将对应的值转换成数字类型)
有关IEEE754
解决办法:在进行小数运算时,要调用数字的toFixed方法,保留指定的小数位数
负数没有开根号,所以为NaN
关系表达式
关系运算符:关系运算符运算结果是布尔值
- <
-
=
- <=
- ==
- !==
- ===
- !=
相等和全等
- 相等:两个等号不比较值的类型,它会进行隐式转换后比较值是否相等
- 全等:三个等号不仅比较值相同也比较类型相同
- null和undefined用==进行比较(涉及隐式强制类型转换,ES5规范中规定)
如果x为null,y为undefined,则结果为true;如果x为null,y为undefined,则结果为true - null和undefined用===进行比较时结果为false是因为类型不同
typeof null //object
typeof undefined //undefined
NaN==NaN //false
NaN===NaN //false
如何判断是否为NaN:isNaN()
逻辑表达式
逻辑运算符
- !
- &&
- ||
短路计算
a&&b运算中:a真,表达式的值为b;a假,表达式的值为a
a||b运算中:a真,表达式的值为a;a假,表达式的值为b
逻辑运算顺序:非----与----或
赋值表达式
赋值运算符
- =
- +=
- -=
- *=
- /=
- %=
- ++
- –
综合表达式
运算顺序:非运算----数学运算----关系运算----逻辑运算
变量的范围表示
// 5<=a<=12
if(a>=5&&a<=12){
}
版权声明
本文为[KK要继续努力]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_45393020/article/details/123459610
边栏推荐
- 锚点定位——如何设置锚点居页面顶部距离,锚点定位并距离顶部一定偏移
- [UDS unified diagnosis service] IV. typical diagnosis service (3) - read fault information function unit (storage data transmission function unit)
- [opencv] use filestorage to read and write eigenvectors
- 在visual stdio中运行qt程序
- C语言实现memcpy、memset、strcpy、strncpy、strcmp、strncmp、strlen
- TP download folder, compress folder and download
- Quaternion multiplication
- 产生随机数
- 卷积神经网络实现CIFAR100数据集分类
- [UDS unified diagnostic service] II. Network layer protocol (1) - overview and functions of network layer
猜你喜欢
逻辑回归原理及代码实现
卷积神经网络实现CIFAR100数据集分类
Running QT program in visual Stdio
Shell脚本 &&和||的使用
Makefile基础、常用函数及通用Makefile
[ThreadX] ThreadX source code reading plan (I)
【UDS统一诊断服务】五、诊断应用示例:Flash Bootloader
欢迎使用Markdown编辑器
Assembler 32-bit unsigned addition calculator
C [document operation] PDF files and pictures are converted to each other
随机推荐
【UDS统一诊断服务】一、诊断概述(2)— 主要诊断协议(K线和CAN)
QT icon application
Introduction and application of WMI Technology
C51/C52 特殊功能寄存器表
[UDS unified diagnostic service] i. overview of diagnosis (4) - basic concepts and terms
FOC电机库 定点PID代码分析
C [document operation] PDF files and pictures are converted to each other
产生随机数
VHDL-任意分频器(50%占空比)
Error in created hook: “ReferenceError: “Promise”未定义“
cv_bridge 与opencv 版本不匹配的解决
SDOI2009-HH的项链
基于TensorFlow的线性回归实例
[ThreadX] h743 + ThreadX + Filex migration record
欢迎使用Markdown编辑器
监听除某元素之外点击事件
记第一次使用阿里字体图标库
Palindromic Primes
软件工程中的十三种文档
HDU-Tunnel Warfare