My colleague wrote a line of ES6 code ...
return map(orderedContentUuids, contentUuid => { uuid: contentUuid });
As you probably can assume that he intended to return the {uuid: contentUuid } object, but since its function is with an arrow, the curly brace { actually starts a new block. (The correct code would be return map(orderedContentUuids, contentUuid => ({ uuid: contentUuid })); ).
But, unexpectedly, this code translates and runs without errors. There is no error because uuid: contentUuid seems to be evaluated before contentUuid .
You can see that if you enter the JavaScript console foo: 'bar' , it will be "bar" .
A? What's happening. Since when is this correct, JS?
source share