我有两个看起来像这样的数组:
const classes = ["story-body-text", "story-content", "leading__100"];
const prefixes = ["alignment__", "font__", "leading__", "size__", "tracking__", "features__"];
我需要遍历classes
数组并删除任何不以prefixes
数组中的值开头的值。在这个特定的实例中,它应该返回一个值为:
return ["leading__100"];
建议?
答案 0 :(得分:0)
_.filter(classes, cls => _.some(prefixes, p => _.startsWith(cls, p)))