Search code examples
javascriptspread-syntaxnumber-literal

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


I just found {....0} in friend's code. Evaluating it in console returns {} (empty object).

Why is that? What is the meaning of 4 dots in JavaScript?


Solution

  • 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 {}.