GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing ko.javascript.info — 배열과 관련된 연산

  • 튜토리얼
  • 코어 자바스크립트
  • 자료구조와 자료형
  • 배열
돌아가기

배열과 관련된 연산

중요도: 5

배열과 관련된 다섯 가지 연산을 해봅시다.

  1. 요소 “Jazz”, "Blues"가 있는 styles 배열을 생성합니다.
  2. "Rock-n-Roll"을 배열 끝에 추가합니다.
  3. 배열 정 중앙에 있는 요소를 "Classics"로 바꿉니다. 가운데 요소를 찾는 코드는 요소가 홀수 개인 배열에서도 잘 작동해야 합니다.
  4. 배열의 첫 번째 요소를 꺼내서 출력합니다.
  5. "Rap"과 "Reggae"를 배열의 앞에 추가합니다.

단계를 하나씩 거칠 때마다 배열 모습은 아래와 같이 변해야 합니다.

Jazz, Blues
Jazz, Blues, Rock-n-Roll
Jazz, Classics, Rock-n-Roll
Classics, Rock-n-Roll
Rap, Reggae, Classics, Rock-n-Roll
let styles = ["Jazz", "Blues"];
styles.push("Rock-n-Roll");
styles[Math.floor((styles.length - 1) / 2)] = "Classics";
alert( styles.shift() );
styles.unshift("Rap", "Reggae");
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.