Created
October 18, 2022 13:08
-
-
Save NewEXE/4b9c61a8f60027d23f99e100f07d1947 to your computer and use it in GitHub Desktop.
JS spread operator: exclude properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example: exclude (separate) 'notifyUser' property from 'request' object | |
const request = { | |
id: 1, | |
title: 'ID 1 title', | |
notifyUser: true | |
}; | |
const { notifyUser, ...updateSet } = request; | |
console.log( | |
notifyUser, // true | |
updateSet // { id: 1, title: 'ID 1 title' } | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment