Open In App

Underscore.js _.neq() Method

Improve
Improve
Like Article
Like
Save
Share
Report

The _.neq() method checks whether each argument is not equal to the previous argument, using loose inequality (!=). Hence, returning a boolean correspondingly.

Syntax:

_.neq( val1, val2, ..., valn );

Parameters: This method takes n values to operate on them.

Return Value: This method returns a boolean.

Note: This will not work in normal JavaScript because it requires the underscore.js contrib library to be installed.

underscore.js contrib library can be installed using npm install underscore-contrib –save.

Example 1: In this example, we will see the use of the _.neq() method.

javascript




// Defining underscore contrib variable
const _ = require('underscore-contrib');
 
let 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: In this example, we will see the use of the _.neq() method.

javascript




// Defining underscore contrib variable
const _ = require('underscore-contrib');
 
let neq = _.neq(4, 4);
 
console.log("Each arguments are not equal to previous one :", neq);


Output:

Each arguments are not equal to previous one : false

Example 3: In this example, we will see the use of the _.neq() method.

javascript




// Defining underscore contrib variable
const _ = require('underscore-contrib');
 
let neq = _.neq(4, 2, 1);
 
console.log("Each arguments are not equal to previous one :", neq);


Output:

Each arguments are not equal to previous one : true

Example 4: In this example, we will see the use of the _.neq() method.

javascript




// Defining underscore contrib variable
const _ = require('underscore-contrib');
 
let neq = _.neq(2, 2, 2);
 
console.log("Each arguments are not equal to previous one :", neq);


Output:

Each arguments are not equal to previous one : false


Last Updated : 10 Apr, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads