Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Build lodash.omit from Scratch with forEach and for...in

    _.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.

    • 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


    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 covers one approach.