Created
September 22, 2022 12:18
-
-
Save theer1k/ec16a6b09481495114c1a5b3dfbab328 to your computer and use it in GitHub Desktop.
Omit object 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
/** | |
* Create an object composed without ommited object properties | |
* @param {Object} object | |
* @param {string} keys | |
* @returns {Object} | |
*/ | |
const omit = (obj, ...keys) => Object.fromEntries( | |
Object.entries(obj) | |
.filter(([key]) => !keys.includes(key)) | |
); | |
module.exports = omit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment