Q:

Why do I get a syntax error when using a spread operator?

I'm using ES6's spread operator with Babel as a transpiler to ES5. When I use the spread operator like so:
const { height, weight, radius, ...otherValues } = sphere;

I get a SyntaxError:
ERROR in ./src/sphere.js
Module build failed: SyntaxError: Unexpected token (7:36)

   6 | 
>  7 |   const { height, weight, radius, ...otherValues } = sphere;
     |                                   ^
   8 | 

Why is this?

A:

Babel doesn't transpile the spread operator out of the box. You also need to install the babel-plugin-transform-object-rest-spread plugin for Babel. Once you've installed that package, your code should compile with no further changes.

