Prototype-enum-include

提供:Dev Guides
2020年6月23日 (火) 02:07時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

プロトタイプ-列挙可能なinclude()メソッド

このメソッドは、==比較演算子に基づいて、指定されたオブジェクトがEnumerableにあるかどうかを判断します。 これは、member()メソッドのエイリアスです。

特定の述語に一致する要素があるかどうかを確認する必要がある場合は、代わりにany()メソッドを使用します。

構文

Iterator.include(object);

戻り値

指定されたオブジェクトが見つかった場合はtrue、それ以外の場合はfalseを返します。

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

      <script>
         function showResult() {
            alert("$R(1,15).include(10) : " + $R(1,15).include(10) );
           //Returns true

            alert("['hello', 'world'] : " + $R(1,15).include('HELLO') );
           //Returns false
         }
      </script>
   </head>

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

出力