lodash lets me check for membership of basic data types with includes
:
_.includes([1, 2, 3], 2)
> true
But the following doesn't work:
_.includes([{"a": 1}, {"b": 2}], {"b": 2})
> false
This confuses me because the following methods that search through a collection seem to do just fine:
_.where([{"a": 1}, {"b": 2}], {"b": 2})
> {"b": 2}
_.find([{"a": 1}, {"b": 2}], {"b": 2})
> {"b": 2}
What am I doing wrong? How do I check for the membership of an object in a collection with includes
?
edit:
question was originally for for lodash version 2.4.1, updated for lodash 4.0.0
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…