Prototype-array-each

提供:Dev Guides
移動先:案内検索

プロトタイプ-each()メソッド

このメソッドは、数値インデックスの昇順で配列を繰り返し処理します。

構文

array.each(iterator);

戻り値

配列要素を返します。

<html>
   <head>
      <title>Prototype examples</title>
      <script type = "text/javascript" src = "/javascript/prototype.js"></script>

      <script>
         function showResult() {
            var oldArr = ['Sam', 'Justin', 'Andrew', 'Dan', null, undefined];
            alert("Guys in old Arr" );

            oldArr.each(function(item) {
               alert(item );
            });
         }
      </script>
   </head>

   <body>
      <p>Click the button to see the result.</p>
      <br/>
      <br/>
      <input type = "button" value = "Result" onclick = "showResult();"/>
   </body>
</html>

出力