Create an object from another object in one line in Javascript #ES6
Published in
1 min readApr 11, 2017
Have you ever wanted to pick properties within an object in javascript and output it straightly as a new object? Sure you probably used lodash before but now you’ll be able to do it simply with a one-line killer solution.
One line solution
It uses an arrow function, a self invoked function and the joy of desctructuring assignment.
Solution without arrow function
Solution without destructuring
Liked it ? share the magic :
Build an object from another one in one line : let john = (({age, job}) => ({age, job}))(person)
#ES6 #magic #javascript
That’s it.
Have fun!
Gabin
Data Hunter / Linkedin