- Lodash Tutorial
- Lodash - Home
- Lodash - Overview
- Lodash - Environment Setup
- Lodash - Array
- Lodash - Collection
- Lodash - Date
- Lodash - Function
- Lodash - Lang
- Lodash - Math
- Lodash - Number
- Lodash - Object
- Lodash - Seq
- Lodash - String
- Lodash - Util
- Lodash - Properties
- Lodash - Methods
- Lodash Useful Resources
- Lodash - Quick Guide
- Lodash - Useful Resources
- Lodash - Discussion
Lodash - matchesProperty method
Syntax
_.matchesProperty(source)
Creates a function that performs a partial deep comparison between the value at path of a given object to srcValue, returning true if the object value is equivalent, else false.
Arguments
path (Array|string) − The path of the property to get.
srcValue (*) − The value to match.
Output
(Function) − Returns the new spec function.
Example
var _ = require('lodash'); var objects = [ { 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 } ]; var result = _.find(objects, _.matchesProperty('a', 4)); console.log(result);
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
{ a: 4, b: 5, c: 6 }
lodash_util.htm
Advertisements
To Continue Learning Please Login
Login with Google