search

Home  >  Q&A  >  body text

JavaScript about operator precedence

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 (. [] ())

滿天的星座滿天的星座2825 days ago506

reply all(1)I'll reply

  • 迷茫

    迷茫2017-05-19 10:30:13

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

    new without parameter list new Foo One level lower.

    reply
    0
  • Cancelreply