sitelink1 | |
---|---|
sitelink2 | |
sitelink3 | |
sitelink4 | |
extra_vars4 | |
extra_vars5 | |
extra_vars6 |
http://www.w3schools.com/jsref/jsref_unshift.aspunshift 펑션은 배열의 0번째에 element를 새로 추가한다. 이때 기존값들은 자동적으로 index가 1 증가한다.
Definition and Usage
The unshift() method adds one or more elements to the beginning of an array and returns the new length.
Syntax
arrayObject.unshift(newelement1,newelement2,....,newelementX) |
Parameter | Description |
---|---|
newelement1 | Required. The first element to add to the array |
newelement2 | Optional. The second element to add to the array |
newelementX | Optional. Several elements may be added |
Tips and Notes
Note: This method changes the length of the array.
Note: The unshift() method does not work properly in Internet Explorer!
Tip: To add one or more elements to the end of an array, use the push() method.
Example
In this example we will create an array, add an element to the beginning of the array and then return the new length:
|
The output of the code above will be:
Jani,Hege,Stale |
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
50 | Iframe 내의 페이지 접근방법 | 황제낙엽 | 2009.11.12 | 59 |
49 | 외부 라이브러리 (.js) 의 바람직한 동적 로딩 (The best way to load external JavaScript) | 황제낙엽 | 2009.10.05 | 124 |
48 | 숫자값으로의 변환 형태 | 황제낙엽 | 2009.09.02 | 18 |
47 | Boolean 데이터 타입 | 황제낙엽 | 2009.09.02 | 16 |
46 | toString 변환 테이블 | 황제낙엽 | 2009.09.02 | 13 |
45 | URI 인코딩을 해야 하는 문자들 | 황제낙엽 | 2009.09.02 | 23 |
44 | 이미지 로드 코드 | 황제낙엽 | 2009.06.27 | 18 |
43 | 자동 형변환 (문자열 -> 숫자) | 황제낙엽 | 2009.06.25 | 124 |
42 | 자바스크립트 쿠키 | 황제낙엽 | 2009.06.11 | 15 |
41 | 테이블 엘리먼트 생성 스크립트 | 황제낙엽 | 2009.04.07 | 14 |
» | unshift() Method | 황제낙엽 | 2009.03.02 | 287 |
39 | 소숫점을 포함한 반올림 | 황제낙엽 | 2008.12.11 | 62 |
38 | int * float 연산 오류 | 황제낙엽 | 2008.12.11 | 95 |
37 | JavaScript Form Validation | 황제낙엽 | 2008.11.24 | 186 |
36 | setTimeout() / setInterval() 메소드 | 황제낙엽 | 2008.11.05 | 111 |
35 | String xml 파싱 | 황제낙엽 | 2008.11.03 | 23 |
34 | innerHTML | 황제낙엽 | 2008.11.03 | 93 |
33 | DOM과 innerHTML 방법에 대한 비교 분석 | 황제낙엽 | 2008.11.03 | 94 |
32 | 익명함수의 사용 | 황제낙엽 | 2008.10.14 | 20 |
31 | Javascript 내장객체 Array (배열) | 황제낙엽 | 2008.10.13 | 57 |