Foo.bar = () => { ... }
function Foo() { ... }
Foo.prototype.bar = () => { ... }
new Foo.bar(); (1)
new Foo().bar(); (2)
(1)可以理解为new (Foo.bar)()
(2)实际执行是(new Foo()).bar() =>这不符合运算符优先级规则啊 一元操作符<属性提取与调用函数操作符(. [] ())
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
带参数列表的 new
new Foo()
跟成员访问.bar
是同个优先级,按左往右。不带参数列表的 new
new Foo
低一级。