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 ja.javascript.info — 配列操作

  • チュートリアル
  • JavaScript 言語
  • データ型
  • 配列
レッスンに戻る

配列操作

重要性: 5

5つの配列操作をしてみましょう。

  1. アイテム “Jazz” と “Blues” を持つ配列 styles を作ります。
  2. 末尾に “Rock-n-Roll” を追加します。
  3. 中央の値を “Classics” で置換します。中央値を見つけるコードは奇数の長さの配列で動作する必要があります。
  4. 配列の最初の値を外して表示します。
  5. 配列の先頭に Rap と Reggae を追加します。

処理中の配列はこのようになります:

Jazz, Blues
Jazz, Bues, 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", "Reggie");
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.