Why does {. . . .0} evaluate to {}?

Four dots actually have no meaning. ... is the spread operator, and .0 is short for 0.0.

Spreading 0 (or any number) into an object yields an empty object, therefore {}.


Three dots in an object literal are a spread property, e.g.:

  const a = { b: 1, c: 1 };
  const d = { ...a, e: 1 }; // { b: 1, c: 1, e: 1 }

The last dot with a 0 is a number literal .0 is the same as 0.0. Therefore this:

 { ...(0.0) }

spreads all properties of the number object into the object, however as numbers don't have any (own) properties you get back an empty object.


In a simple terms {...} spread operator in javascript extends one object/array with another.

So, when babelifier tries extending one with another, it has to identify whether it is trying to extend an array or an object.

In the case of array, it iterates over elements.

In the case of object, it iterates over keys.

In this scenario, the babelyfier is trying to extract keys for number by checking the Object's own property call which is missing for number so it returns empty Object.