{
"providerProperties": [
{
"key": "hotelnum",
"value": "123"
},
{
"key": "contract",
"value": "ABC"
},
{
"key": "Sequence",
"value": "1213"
},
{
"key": "lastFourDigit",
"value": "5454"
},
{
"key": "shop",
"value": "abc"
},
{
"key": "bookingEmailAddress",
"value": "abc@gmail.COM"
},
{
"key": "numOfRooms",
"value": "1"
}
}
Backbone / chaplinJS:如何检查对象中的密钥存在。 例如,想要检查密钥" numOfRooms"可用与否。
答案 0 :(得分:4)
如果结果不是_.findWhere(yourObject.providerProperties, {key: "numOfRooms"});
,那么您可以使用undefined
这样的下划线方法findWhere