const arrays = [8,1,2,3,4,1]; //循环 arrays.forEach(value => console.log(value)); //降序 arrays.sort((v1,v2)=>{ return v2-v1}); console.log(arrays); //升序 arrays.sort((v1,v2)=>{ return v1-v2}); console.log(arrays);