func=(a,b)=>{ b=b.sort(); return !a.sort().some((el,i)=>el !== b[i]); }; alert(func([12, 5, 8, 44, 130,],[12, 5, 8, 130, 44]));