JavaScript about operator precedence
滿天的星座
滿天的星座 2017-05-19 10:28:13
0
1
490

Foo.bar = () => { ... }

function Foo() { ... }

Foo.prototype.bar = () => { ... }

new Foo.bar(); (1)

new Foo().bar(); (2)

(1) can be understood as new (Foo.bar)()

(2)The actual execution is (new Foo()).bar() =>This does not comply with the operator precedence rules. Unary operator<Attribute extraction and calling function operator (. [] ())

滿天的星座
滿天的星座

reply all(1)
迷茫

new new Foo() 跟成员访问 .barwith parameter list has the same priority, from left to right.

new without parameter list new Foo One level lower.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template