Is it possible to destructure onto an existing object? (Javascript ES6)

For example if I have two objects:

var foo = {
  x: "bar",
  y: "baz"
}

and

var oof = {}

and I wanted to transfer the x and y values from foo to oof. Is there a way to do that using the es6 destructuring syntax?

perhaps something like:

oof{x,y} = foo

116 thoughts on “Is it possible to destructure onto an existing object? (Javascript ES6)”

Leave a Comment