js判断字符是否存在数组中
程序员文章站
2022-04-14 16:13:38
~~~javascript //检测某个字符是否在此数组中 function isInArray(arr, str) { var testStr = ',' + arr.join(",") + ","; return testStr.indexOf("," + str + ",") != 1 ; } ......
//检测某个字符是否在此数组中 function isinarray(arr, str) { var teststr = ',' + arr.join(",") + ","; return teststr.indexof("," + str + ",") != -1 ; } var arr = ["101", "102", "103"]; console.log(isinarray(arr,"101"));//true
文章转自:https://blog.csdn.net/weixin_38052444/article/details/81805870
上一篇: 18.面向对象-----super关键字
下一篇: webapi生成dll文件