const {name, slug, description, parent} = cat;
const saneCat = {name, slug, description, parent};
In the first expression, we define four constants by destructuring a messy object. In the second expression, we combine them into a new object. I would like to do this in a single step without duplicating the list of interesting fields, but because the first expression doesn't define an object, this seems to be impossible. Is it really? We are so close to a Clojurian win!
I have tried the following without success. Any ECMAScript compiler is fair game, but I don't have the option of just using Clojurescript.
const saneCat = {name, slug, description, parent} = cat; // name is not defined
const {...saneCat} = {name, slug, description} = cat; // name is not defined
const saneCat = ({name, slug, description, parent} = cat); // name is not defined
const saneCat = ({name, slug, description, parent}) = cat; // name is not defined
const saneCat = {{name, slug, description, parent}} = cat; // unexpected token
const saneCat = {{name, slug, description, parent}} = {cat}; // unexpected token