企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## isMatchWith + [link](./isMatchWith "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L10029 "View in source.") + [npm](https://www.npmjs.com/package/lodash.ismatchwith "See the npm package.") ``` _.isMatchWith(object, source, [customizer]) ``` 这个方法类似 `_.isMatch`。 除了它接受一个 customizer 定制比较的值。 如果 customizer 返回 undefined 将会比较处理方法代替。 customizer 会传入5个参数:(objValue, srcValue, index|key, object, source) ### 参数 1. object (Object) 要检查的值 2. source (Object) 匹配包含在 object 的对象 3. [customizer] (Function) 这个函数定制比较值 ### 返回值 (boolean) 如果匹配返回 `true`,否则返回 `false` ### 示例 ``` function isGreeting(value) { return /^h(?:i|ello)$/.test(value); } function customizer(objValue, srcValue) { if (isGreeting(objValue) && isGreeting(srcValue)) { return true; } } var object = { 'greeting': 'hello' }; var source = { 'greeting': 'hi' }; _.isMatchWith(object, source, customizer); // => true ```