NodeJS - lodash utility


Example of lodash module utilities.

const _ = require('lodash');

Utility Example 1: Example of Unique array filter.

console.log(_.uniq([1,2,3,1]));
// it prints [ 1, 2, 3 ]

Utility Example 2: Example of Unique array filter.

console.log(_.uniq(['Sagar', 'Kothari', 1, 2, 3, 1, 'Sagar']));
// it prints [ 'Sagar', 'Kothari', 1, 2, 3 ]

Utility Example 3: Validation

console.log(_.isString(true));
// it prints false

Utility Example 4: Validation

console.log(_.isString('Sagar'));
// it prints true