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