Open In App
Related Articles

Lodash _.eq() Method

Improve Article
Improve
Save Article
Save
Like Article
Like

The _.eq() method is used to find the two values are equivalent or not by performing the SameValueZero comparison. It returns true, if the values are equivalent. Otherwise, it returns false.

Syntax:

_.eq(value, other)

Parameters: This method accepts two parameters as mentioned above and described below:

  • value: This parameter holds the value to compare.
  • other: This parameter holds the other value to compare.

Return Value: This method returns true if the values are equivalent, else false.

Example 1:

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
       
// Use of _.eq method 
console.log(_.eq("Geeks", "Geeks" )); 
console.log(_.eq("Geeks", Object("Geeks"))); 
console.log(_.eq(NaN, NaN)); 

Output:

true
false
true

Example 2:  

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
  
// Given values
var object = { 'gfg': 2020 };
var other = { 'gfg': 2020 };
  
// Use of _.eq method 
console.log(_.eq(object, object)); 
console.log(_.eq(object, other)); 

Output:

true
false
Last Updated : 09 Sep, 2020
Like Article
Save Article
Similar Reads
Related Tutorials