Tuesday, 23 June, 2020 UTC


Summary

`_.omit` and its sibling `_.pick` are popular utilities which apply filter-like functionality to objects. This lesson will demonstrate two techniques for building the functionality found in [_.omit](https://lodash.com/docs/4.17.15#omit). - Cloning the object with `Object.assign` and removing unwanted keys with `delete` - Using `for...in` and `.includes` to manually copy keys into a `result` object **Notes**: In modern JavaScript environments instead of `Object.assign({}, obj)` you can also use `{ ...obj }` which will have the same effect of a shallow copy. This lesson will not cover how to emulate `_.omit`'s support for taking either an array or multiple arguments for its keys, but our video on [building _.pick from scratch](https://egghead.io/lessons/javascript-build-lodash-pick-from-scratch) covers one approach. ---- - [MDN Guide: Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)