JavaScript表达式

算术表达式 (Arithmetic expressions)

Under this category go all expressions that evaluate to a number:

在此类别下,取所有计算结果为数字的表达式:

1 / 2
i++
i -= 2
i * 2

字符串表达式 (String expressions)

Expressions that evaluate to a string:

计算结果为字符串的表达式:

'A ' + 'string'

主要表达 (Primary expressions)

Under this category go variable references, literals and constants:

在此类别下,变量引用,文字和常量:

2
0.02
'something'
true
false
this //the current object
undefined
i //where i is a variable or a constant

but also some language keywords:

还有一些语言关键字:

function
class
function* //the generator function
yield //the generator pauser/resumer
yield* //delegate to another generator or iterator
async function* //async function expression
await //async function pause/resume/wait for completion
/pattern/i //regex
() // grouping

数组和对象初始化器表达式 (Array and object initializers expressions)

[] //array literal
{} //object literal
[1,2,3]
{a: 1, b: 2}
{a: {b: 1}}

逻辑表达式 (Logical expressions)

Logical expressions make use of logical operators and resolve to a boolean value:

逻辑表达式使用逻辑运算符并解析为布尔值:

a && b
a || b
!a

左侧表达式 (Left-hand-side expressions)

new //create an instance of a constructor
super //calls the parent constructor
...obj //expression using the spread operator

See the spread operator tutorial

请参阅传播算子教程

属性访问表达式 (Property access expressions)

object.property //reference a property (or method) of an object
object[property]
object['property']

对象创建表达式 (Object creation expressions)

new object()
new a(1)
new MyRectangle('name', 2, {a: 4})

函数定义表达式 (Function definition expressions)

function() {}
function(a, b) { return a * b }
(a, b) => a * b
a => a * 2
() => { return 2 }

调用表达式 (Invocation expressions)

The syntax for calling a function or method

调用函数或方法的语法

a.x(2)
window.resize()

翻译自: https://flaviocopes.com/javascript-expressions/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值