Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.
The _.neq() method checks whether each argument is not equal to the previous argument, using loose inequality (!=) and returning a boolean correspondingly.
Syntax:
_.neq( val1, val2, ..., valn )
Parameters: This method takes a variable number of values to operate on them.
Return Value: This method returns a boolean value.
Note: This will not work in normal JavaScript because it requires the lodash contrib library to be installed. The Lodash contrib library can be installed using npm install lodash-contrib –save.
Example 1:
Javascript
// Defining lodash contrib variable var _ = require( 'lodash-contrib' ); // Using the _.neq() method var neq = _.neq( 3, 1 ); console.log( "Each arguments are not equal " + "to previous one :" , neq ); |
Output:
Each arguments are not equal to previous one : true
Example 2:
Javascript
// Defining lodash contrib variable var _ = require( 'lodash-contrib' ); // Using the _.neq() method var neq = _.neq( 8, 8 ); console.log( "Each arguments are not equal " + "to previous one :" , neq ); |
Output:
Each arguments are not equal to previous one : false
Example 3:
Javascript
// Defining lodash contrib variable var _ = require( 'lodash-contrib' ); // Using the _.neq() method var neq = _.neq( 8, 6, 4, 12 ); console.log( "Each arguments are not equal " + "to previous one :" , neq ); |
Output:
Each arguments are not equal to previous one : true
Example 4:
Javascript
// Defining lodash contrib variable var _ = require( 'lodash-contrib' ); // Using the _.neq() method var neq = _.neq( 8, 8, 8, 8 ); console.log( "Each arguments are not equal " + "to previous one :" , neq ); |
Output:
Each arguments are not equal to previous one : false