Typescript 把Lambdas放在语句中

Typescript 把Lambdas放在语句中,typescript,Typescript,有人能解释为什么第二个例子不起作用: var thisWorks = true || function () {}; var thisBreaks = true || () => {}; 使用: 我认为这与运营商的优先权有关 var thisBreaks = true || (()=>{ }) ; 编译为javascript: var thisBreaks = true || (function () { }); var thisBreaks = true || (); { }

有人能解释为什么第二个例子不起作用:

var thisWorks = true || function () {};
var thisBreaks = true || () => {};
使用:

我认为这与运营商的优先权有关

var thisBreaks = true || (()=>{ }) ;
编译为javascript:

var thisBreaks = true || (function () { });
var thisBreaks = true || ();
{ }
;

var thisBreaks = true || ()=>{};
编译为javascript:

var thisBreaks = true || (function () { });
var thisBreaks = true || ();
{ }
;
在这里试试你自己: 使用:

我认为这与运营商的优先权有关

var thisBreaks = true || (()=>{ }) ;
编译为javascript:

var thisBreaks = true || (function () { });
var thisBreaks = true || ();
{ }
;

var thisBreaks = true || ()=>{};
编译为javascript:

var thisBreaks = true || (function () { });
var thisBreaks = true || ();
{ }
;
在这里试试你自己:

这就是ECMAScript 6中各种运算符的优先级的工作方式


这里有一个很好的解释,它按顺序遍历每个产品。

这就是ECMAScript 6中各种操作符的优先级是如何工作的

这里有一个很好的解释,按顺序介绍每一个产品