博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
javascript运算符_JavaScript运算符优先级规则
阅读量:2502 次
发布时间:2019-05-11

本文共 913 字,大约阅读时间需要 3 分钟。

javascript运算符

Every complex statement will introduce precedence problems.

每个复杂的语句都会引入优先级问题。

Take this:

拿着这个:

const a = 1 * 2 + 5 / 2 % 2

The result is 2.5, but why? What operations are executed first, and which need to wait?

结果是2.5,但是为什么呢? 首先执行哪些操作,哪些需要等待?

Some operations have more precedence than the others. The precedence rules are listed in this table:

一些操作比其他操作具有更高的优先级。 优先级规则在此表中列出:

Operator Description
- + ++ -- unary operators, increment and decrement
* / % multiply/divide
+ - addition/subtraction
= += -= *= /= %= **= assignments
操作员 描述
- + ++ -- 一元运算符,递增和递减
* / % 乘/除
+ - 加/减
= += -= *= /= %= **= 作业

Operations on the same level (like + and -) are executed in the order they are found

同一级别的操作(如+- )将按找到的顺序执行

Following this table, we can solve this calculation:

遵循此表,我们可以解决此计算问题:

const a = 1 * 2 + 5 / 2 % 2const a = 2 + 5 / 2 % 2const a = 2 + 2.5 % 2const a = 2 + 0.5const a = 2.5

翻译自:

javascript运算符

转载地址:http://hqqgb.baihongyu.com/

你可能感兴趣的文章
python菜鸟基础知识(二)
查看>>
Jquery 飘窗
查看>>
mysql 效率 inner join 与 where in
查看>>
linux 定时任务详解
查看>>
PowerShell 远程管理之 about_Remote_Troubleshooting
查看>>
创建Windows服务(Windows Services)N种方式总结
查看>>
Inno Setup入门(五)——添加readme文件
查看>>
openCv学习札记(二)—cv:Mat学习
查看>>
图像处理之哈哈镜的实现
查看>>
跟我一起学C++
查看>>
Android Studio Gradle
查看>>
网络中的「动态路由算法」,你了解吗?
查看>>
html5新特性
查看>>
Effective Java 阅读笔记——枚举和注解
查看>>
Android自动化测试之环境搭建
查看>>
JavaScript运算符
查看>>
html position布局
查看>>
VTP
查看>>
Linux内核分析第一周——计算机是如何工作的
查看>>
Windows 自动启动 bat
查看>>