array 객체
메서드
설명
join()
배열 사이에 지정된 문자열을 추가하기
reverse()
배열을 역순으로 정렬하기
sort()
배열 정렬하기
slice()
배열을 일부 선택하기
concat()
배열을 합치기
shift()
첫 번째 배열 가져오기 또는 제거하기
unshift()
첫 번째 배열 추가하기
pop()
마지막 배열 가져오기 또는 제거하기
const arr10 = [100, 200, 300, 400, 500];
const arr20 = [600, 700, 800, 900, 1000];
document.write(arr10, "<br>");
document.write(arr10.join(''), "<br>");
document.write(arr10.reverse(), "<br>");
document.write(arr10.sort(), "<br>");
document.write(arr10.sort(function(a, b){return b - a}), "<br>");
document.write(arr10.sort(function(a, b){return a - b}), "<br>");
document.write(arr10.slice(1,3), "<br>");
document.write(arr10.slice(2,3), "<br>");
document.write(arr10.concat(arr20), "<br>");
document.write(arr10.shift(), "<br>"); //맨 앞에 값을 가져온다
document.write(arr10, "<br>"); //가져온 값 제외
document.write(arr10.unshift(100), "<br>"); //맨 앞에 값을 추가한다
document.write(arr10, "<br>");
document.write(arr10.pop(), "<br>"); //맨 뒤에 값을 가져온다
document.write(arr10, "<br>"); //가져온 값 제외102페이지 예제
103페이지 예제
Last updated
Was this helpful?