js判断某个元素是否属于一个数组

function IsInArray(arr,val){  
 
          var testStr=','+arr.join(",")+",";  
        
          return testStr.indexOf(","+val+",")!=-1;  
        
        }
posted @ 2020-01-04 23:35  帆酱  阅读(1621)  评论(0编辑  收藏  举报