We know we can use Lodash’s _.omit on an object to return a new object with some keys removed.

const myObject = {
    foo: 'bar',
    baz: 'quux',
    thud: 'grunt',

// We want a new object without the `foo` key/value pair
// The following returns 
// {
//    baz: 'quux',
//    thud: 'grunt',
// }
const myObjectWithoutFoo = _.omit(myObject, 'foo');

But what if we have an array and we just want to remove a specific value from the array?


Suppose now we have the following:

const myArray = ['foo', 'bar', 'baz'];

To remove a specific value from the array, we can use JavaScript’s Array.prototype.filter function.

const myArray = ['foo', 'bar', 'baz'];

// returns ['bar', 'baz']
const myArrayWithoutFoo = myArray.filter(val => val !== 'foo');