Why is this valid syntax?

When destructuring an object you chose which properties you need:

const {a, c} = {'c': 1, 'b': 2, 'a': 3};

Thus having no parameters is acceptable, but useless nonetheless:

const {} = {};

It's just the limiting case of object destructuring.

While it may seem pointless to allow it, allowing edge cases like this is useful for automatically generated code, so the generator doesn't have to check that there are zero items and skip generating the code.


Yes, empty destructuring like that is perfectly fine, it's just useless. This is covered in Runtime Semantics: DestructuringAssignmentEvaluation

With parameter value.

ObjectAssignmentPattern: {}

  1. Perform ? RequireObjectCoercible(value).

  2. Return NormalCompletion(empty).

All it does (in RequireObjectCoercible) is require that the right side is not null nor undefined.