While refactoring some code I accidentally discovered that this is valid syntax (or at least, doesn't cause a parser error in Firefox):
const {} = somefunc();
somefunc
returns an object
and the curly's are supposed to contain variable names for destructuring, at the time I hadn't decided what those names would be so I temporarily left them empty.
The editor didn't highlight a syntax error, so out of curiosity I tested it, and was surprised that Firefox actually had no issue with this syntax.
Why is this syntax valid? Does it actually do something weird?
Yes, empty destructuring like that is perfectly fine, it's just useless. This is covered in Runtime Semantics: DestructuringAssignmentEvaluation
With parameter value.
ObjectAssignmentPattern:
{}
Perform ? RequireObjectCoercible(value).
Return NormalCompletion(empty).
All it does (in RequireObjectCoercible) is require that the right side is not null nor undefined.