const articles = [
{title: 'title 1', published: false, pages: 30, tags: {name: 'work', id: 1, visibility: "everyone"}},
{title: 'title 2', published: false, pages: 25, tags: {name: 'home', id: 3, visibility: "myself"}},
{title: 'title 3', published: true, pages: 30, tags: {name: 'vacation', id: 5, visibility: "myself"}}
];
我的JSON数据大致如下,我需要根据
published
为真且visibility
是自己的值进行过滤。如何以有效的方式实现这一点?感谢您的帮助。到目前为止,我只能使用单个属性进行过滤。
R.filter(R.propEq("published", false))(articles);
R.allPass
代替R.and
。 - Scott Sauyetboth
而不是and
吗?R.and
似乎不能接受谓词。https://ramdajs.com/docs/#and - Hitmandsand
和or
来代替&&
和||
。在很多方面,我更希望它们扮演both
和either
现在所扮演的角色。 - Scott Sauyet