Lodash - omit method



Syntax

_.omit(object, [paths])

The opposite of _.pick; this method creates an object composed of the own and inherited enumerable property paths of object that are not omitted.

Arguments

  • object (Object) − The source object.

  • [paths] (...(string|string[])) − The property paths to omit.

Output

  • (Object) − Returns the new object.

Example

var _ = require('lodash');
var object = { 'a': 1, 'b': '2', 'c': 3 };
var result = _.omit(object, ['a', 'b']);

console.log(result);

Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

Output

{ c: 3 }
lodash_object.htm
Advertisements