【发布时间】:2016-04-26 11:47:54
【问题描述】:
我需要通过两个属性和他在集合中的值来找到一些对象,比如在 loDash 中:
_.where(collection, searchObject)
只区分大小写。
我该怎么做?
有对象:
[{
"city": "New York, US",
"name": "John",
"address": "Allen Street, 0123",
},{
"city": "New York, US",
"name": "Dale",
"address": "Barrow Street, 3210",
}];
我需要传递一个类似于
的参数{
"city": 'new york, US'
"address": "Barrow street, 3210"
}
并找到第二个对象作为结果。
这个逻辑在 loDash 或 Underscore 中提供了一个 _.where 函数,但他的搜索不会区分大小写。
【问题讨论】:
-
尝试发布更多代码
标签: javascript object search lodash where-clause