Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Lodash-Array
  • Lodash-Collection
  • Lodash-Function
  • Lodash-Lang
  • Lodash-Math
  • Lodash-Object
  • Lodash-Sequence
  • Lodash-String
  • Lodash-Util
  • JavaScript
  • Web Technology
Open In App

Lodash _.matches() Method

Last Updated : 25 Oct, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

Lodash _.matches method creates a function that performs a partial deep comparison between a given object and source, returning true if the given object has equivalent property values, else false.

Syntax:

_.matches(source);

Parameter:

  • source: The object of property values to match.

Return Value:

It returns the new spec function.

Example 1: In this example, we are printing the matching value to the given array of objects by using the _.matches() method.

javascript
// Requiring the lodash library   const _ = require("lodash");  // Using _.matches() method let geek = [{ 'java': 3, 'python': 5, 'js': 7 }, { 'java': 4, 'python': 2, 'js': 6 } ];  let gfg = _.filter(geek, _.matches({ 'java': 3, 'js': 7 }));  // Storing the Result console.log(gfg); 

Output:

[Object {java: 3, js: 7, python: 5}]

Example 2: In this example, we are printing the matching value to the given array of objects by using the _.matches() method.

javascript
// Requiring the lodash library   const _ = require("lodash");  // Using _.matches() method let objects = [     { 'a': 1, 'b': 2, 'c': 3 },     { 'a': 4, 'b': 5, 'c': 6 },     { 'a': 8, 'b': 7, 'c': 9 } ];  let gfg = _.filter(objects, _.matches({ 'a': 8 })); console.log(gfg) 

Output:

[ {a: 8, b: 7, c: 9}]

J

jana_sayantan
Improve
Article Tags :
  • JavaScript
  • Web Technologies
  • JavaScript-Lodash

Similar Reads

    Lodash _.bindAll() Method
    Lodash _.bindAll() method is used to bind the number of methods on the object. Each method is given a method name. It is handy to work with the event handlers. Syntax:_.bindAll(object, methodNames)Parameter: This method accepts two parameters as mentioned above and described below: object: It is the
    2 min read
    Lodash _.cond() Method
    Lodash _.cond method creates a function that iterates over pairs and invokes the corresponding function of the first predicate to return truthy. The predicate-function pairs are invoked with the binding and arguments of the created function. Syntax:_.cond(pairs);Parameters: pairs: [Array]The predica
    2 min read
    Lodash _.conforms() Method
    Lodash _.conforms() method of Util is used to create a function that calls the predicate properties of the source with the analogous property values of a stated object, which returns true if all the predicates are true else returns false. Syntax:_.conforms(source);Parameters: source (Object): It is
    2 min read
    Lodash _.constant() Method
    Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc. The _.constant method is used to create a function that returns value. Syntax: _.constant(value) Parameters: This method accepts one parameter as mentioned abov
    1 min read
    Lodash _.defaultTo() Method
    Lodash _.defaultTo() method is used to check the given value and determine if a default value should be restored in its place. When the value is NaN, null, or undefined, the value given in the defaultValue parameter is returned. Syntax:_.defaultTo( value, defaultValue );Parameters: value: This param
    1 min read
    Lodash _.flow() Method
    Lodash _.flow() method is used to generate a new composite function that returns the result of invoking the provided functions with the binding of the function generated. Each of the successive invocations is provided the return value of the previous. Syntax:_.flow([funcs]);Parameters: funcs: This p
    2 min read
    Lodash _.flowRight() Method
    Lodash _.flowRight() method is used to create a new composite function that invokes the provided functions from right to left, where each of the successive invocations is provided the return value of the previous. It is almost the same as the _.flow() method. Syntax:_.flowRight(funcs);Parameters: fu
    2 min read
    Lodash _.identity() Method
    Lodash _.identity method returns the first argument it receives. Syntax:_.identity(value);Parameters: value: It can be any value.Return Value:Returns the first argument it receives. Example 1: In this example, it is returning the first parameter because of the lodash _.identity() method. javascript
    1 min read
    Lodash _.iteratee() Method
    Lodash_.iteratee method  creates a function that invokes func with the arguments of the created function. If func is a property name, the created function returns the property value for a given element. If func is an array or object, the created function returns true for elements that contain the eq
    2 min read
    Lodash _.matches() Method
    Lodash _.matches method creates a function that performs a partial deep comparison between a given object and source, returning true if the given object has equivalent property values, else false. Syntax:_.matches(source);Parameter:source: The object of property values to match.Return Value:It retur
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences