We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

번역 작업 진행중입니다.

unshift() 메소드(method)는  새로운 요소(element)를 배열(array)의 맨 앞쪽에 추가하고자 할 때 사용한다. return 값은 새로운 요소가 추가된 배열이다. 


arr.unshift([element1[, ...[, elementN]]])


배열 맨 앞에 추가할 요소들.


새로운 배열의 length 속성.


unshift 메소드는 배열 과 같은 객체의 시작점에 주어진 값(요소)을 삽입한다.

unshift is intentionally generic; this method can be called or applied to objects resembling arrays. Objects which do not contain a length property reflecting the last in a series of consecutive, zero-based numerical properties may not behave in any meaningful manner.


var arr = [1, 2];

arr.unshift(0); // result of call is 3, the new array length
// arr is [0, 1, 2]

arr.unshift(-2, -1); // = 5
// arr is [-2, -1, 0, 1, 2]

// arr is [[-3], -2, -1, 0, 1, 2]


Specification Status Comment
ECMAScript 3rd Edition (ECMA-262) Standard Initial definition. Implemented in JavaScript 1.2.
ECMAScript 5.1 (ECMA-262)
The definition of 'Array.prototype.unshift' in that specification.
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Array.prototype.unshift' in that specification.

브라우저 호환성

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 1.0 (1.7 or earlier) 5.5 (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)


문서 태그 및 공헌자

이 페이지의 공헌자: jisooyu, maytree
최종 변경: jisooyu,