gpt4 book ai didi

javascript - 在数组中 & 在字符串中

转载 作者:行者123 更新时间:2023-11-30 10:44:29 25 4
gpt4 key购买 nike

我需要检查一个字符串是否在数组中作为数组中任何项目的字符串的一部分。假设数组中的一项是“Hello World”,字符串是“ello”,我需要它返回 true。

最佳答案

是的,你可以做到这一切。或者-

if(String(array).indexOf('ello')!=-1){
ello is in the array
}

关于javascript - 在数组中 & 在字符串中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9223354/

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