跳到主要内容

where

_.where(list, properties)
遍历 list 中的每一个值,返回一个数组,这个数组里的元素包含 properties 所列出的键 - 值对。

_.where(listOfPlays, {author: "Shakespeare", year: 1611});
=> [{title: "Cymbeline", author: "Shakespeare", year: 1611},
{title: "The Tempest", author: "Shakespeare", year: 1611}]