gpt4 book ai didi

javascript - 如何从数组中获取值,其中包含一些带有lodash angular 4的值

转载 作者:行者123 更新时间:2023-11-30 19:34:16 25 4
gpt4 key购买 nike

嘿,我有这个数组

[
0: "Migration, MD"
1: "Lution, MD"
2: "Mover, MD"
3: "Dee"
4: "Prov10A"
]

如何获取其中包含单词MD的值就像它有 MD 它应该给我这样的东西

[
0: "Migration, MD"
1: "Lution, MD"
2: "Mover, MD"
]

我如何使用 lodash 做到这一点?谢谢

最佳答案

使用filterincludes:

const arr = ["Migration, MD", "Lution, MD", "Mover, MD", "Dee", "Prov10A"];
const res = arr.filter(e => e.includes("MD"));
console.log(res);
.as-console-wrapper { max-height: 100% !important; top: auto; }

关于javascript - 如何从数组中获取值,其中包含一些带有lodash angular 4的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56106018/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com