One-liner to take some properties from object in ES 6

Here’s something slimmer, although it doesn’t avoid repeating the list of fields. It uses “parameter destructuring” to avoid the need for the v parameter. ({id, title}) => ({id, title}) (See a runnable example in this other answer). @EthanBrown’s solution is more general. Here is a more idiomatic version of it which uses Object.assign, and computed … Read more

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

While ugly and a bit repetitive, you can do ({x: oof.x, y: oof.y} = foo); which will read the two values of the foo object, and write them to their respective locations on the oof object. Personally I’d still rather read oof.x = foo.x; oof.y = foo.y; or [‘x’, ‘y’].forEach(prop => oof[prop] = foo[prop]); though.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)