Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.
pop() 메서드는 Array 인스턴스의 메서드로, 배열에서 마지막 요소를 제거하고 그 요소를 반환합니다. 이 메서드는 배열의 길이를 변경합니다.
없음.
배열에서 제거한 요소. 빈 배열의 경우 undefined 를 반환합니다.
pop() 메서드는 배열에서 마지막 요소를 제거하고 그 값을 호출자에게 반환합니다. 빈 배열에서 pop()을 호출하면 undefined를 반환합니다.
Array.prototype.shift()는 pop()과 유사한 동작을 하지만 배열의 첫 번째 요소에 적용됩니다.
pop() 메서드는 배열을 변경시키는 메서드입니다. this의 길이와 내용을 변경합니다. this의 값을 그대로 유지하면서 마지막 요소가 제거된 새 배열을 반환하고 싶다면 대신 arr.slice(0, -1)을 사용할 수 있습니다.
pop() 메서드는 범용 메서드입니다. this 값이 length 속성과 정수 키 속성만 있으면 됩니다. 문자열도 배열과 유사하지만, 문자열은 불변이기 때문에 이 메서드를 문자열에 적용하는 것은 적절하지 않습니다.
다음 코드는 4개의 요소가 있는 myFish 배열을 생성하고 마지막 요소를 제거합니다.
pop() 메서드는 this의 length 속성을 읽습니다. 정규화된 길이가 0이면 length는 다시 0으로 설정됩니다(이전에는 음수나 undefined일 수 있음). 그렇지 않으면 length - 1 위치의 속성이 반환되고 삭제됩니다.
push와 pop은 의도적으로 범용 메서드로 설계되었으며, 다음 예제에서 볼 수 있듯이 이를 이용할 수 있습니다.
이 예제에서는 객체의 컬렉션을 저장하기 위해 배열을 만들지 않습니다. 대신, 컬렉션을 객체 자체에 저장하고 Array.prototype.push와 Array.prototype.pop에 call을 사용하여 마치 배열을 다루는 것처럼 속입니다.
| ECMAScript® 2027 Language Specification # sec-array.prototype.pop |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025년 10월 10일 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.