ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
## matchesProperty + [link](./matchesProperty "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L13370 "View in source.") + [npm](https://www.npmjs.com/package/lodash.matchesproperty "See the npm package.") ``` _.matchesProperty(path, srcValue) ``` 创建一个深比较的方法来比较给定对象的 `path` 的值是否是 `srcValue`。 如果是返回 `true`,否则返回 `false` **注意:** 这个方法支持以 `_.isEqual` 的方式比较相同的值。 ### 参数 1. path (Array|string) 给定对象的属性路径名 2. srcValue (\*) 要匹配的值 ### 返回值 (Function) 返回新的函数 ### 示例 ``` var users = [ { 'user': 'barney' }, { 'user': 'fred' } ]; _.find(users, _.matchesProperty('user', 'fred')); // => { 'user': 'fred' } ```