DEV Community

miku86
miku86

Posted on

Diary - 2018.10.23

Object Rest Property

A nice little tool to "split" objects into something new.

// it's me const user = { id: 1, email: 'mario@mariobros.com', firstName: 'Mario', job: 'plumber', }; // we want to get the user without its email (privacy!) const { email, ...userWithoutEmail } = user; console.log(email); // mario@mariobros.com console.log(userWithoutEmail); // ​​​​​{ id: 1, firstName: 'Mario', job: 'plumber' }​​​​​ 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)