Skip to content

Instantly share code, notes, and snippets.

@NewEXE
Created October 18, 2022 13:08
Show Gist options
  • Save NewEXE/4b9c61a8f60027d23f99e100f07d1947 to your computer and use it in GitHub Desktop.
Save NewEXE/4b9c61a8f60027d23f99e100f07d1947 to your computer and use it in GitHub Desktop.
JS spread operator: exclude properties
// 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