I came across unexpected behavior when working with arrow functions in combination with a short circuit rating.
As expected, the following code causes the function to be assigned:
let a = false || function(data) { return data }
However, this same editor-in-chief throws an exception when using arrow functions:
let a = false || (data) => data
Although, if you assigned the arrow function to a variable and then performed the "same" action, but replaced the arrow function for your new variable (a), the result will be what you would expect, the function will be assigned to the variable (b):
let a = (data) => data
let b = false || a //b = (data) => data
Question
What causes this? Is this intentional, and if so, why?
Note
&&, , , || &&, , .
() !
, , . , javascript, .