JavaScript 判斷元素是否在數組中

function isInArray(arr, val) {
    let testStr = ',' + arr.join(",") + ",";
    return testStr.indexOf("," + val + ",") === -1
}
相關文章
相關標籤/搜索