I'm just looking for a reason as to why this is invalid:
() => throw 42;
I know I can get around it via:
() => {throw 42};
I'm just looking for a reason as to why this is invalid:
() => throw 42;
I know I can get around it via:
() => {throw 42};
你不能return throw
这实际上是你想要做的:
function(){
return throw 42;
}
如果在箭头函数中省略大括号,则会创建一个隐式 return,这相当于使用大括号创建一个显式 return ,如下所示:() => { return throw 42 };