logic

Why does “true && () => {}” produce “Uncaught SyntaxError: Malformed arrow function parameter list”? [duplicate]

萝らか妹 提交于 2020-08-22 11:47:21
问题 This question already has answers here : Why does the logical or operator (||) with an empty arrow function (()=>{}) cause a SyntaxError? (3 answers) Closed last year . The following code, when executed, true && () => {} yields Uncaught SyntaxError: Malformed arrow function parameter list Why ? Edit: I know wrapping the function in parenthesis works, thanks everyone, but I'd like to understand why can't the parser figure out it's a function in the first place. 回答1: The reason is due the first