JavaScript 判断元素是否在数组中

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

 

posted @ 2020-05-19 16:46  jingsupo  阅读(553)  评论(2编辑  收藏  举报

欢迎光临