JavaScript 判断元素是否在数组中

function isInArray(arr, val) {
    let testStr = ',' + arr.join(",") + ",";
    return testStr.indexOf("," + val + ",") === -1
}

 

posted @ 2020-05-19 16:46  jingsupo  阅读(236)  评论(2编辑  收藏
我要啦免费统计