let ids = [1, 2, 3, 4, 5]; let ns = ['012', '011', '010']; console.log(ns) //仅适用于一维数组 function seriesArray(array){ let arr = array.slice(0); arr.sort(function(a, b){return a-b}) let flag = true; for(let k=0; k<arr.length; k++){ if(k+1 == arr.length){return flag} if(arr[k+1] - arr[k]!=1){ flag = false; return flag } } } let result = seriesArray(ns); console.log(result)