Prototype-array-without

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

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

このメソッドは、指定された値のいずれも含まない新しいバージョンの配列を生成します。

構文

array.without(value...);

戻り値

要素を指定せずに新しい配列を返します。

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

      <script>
         function showResult() {
            var arr = ['Sam', 'Justin', 'Andrew', 'Dan', 'Sam'];
            alert("Without Sam : "  + arr.without('Sam').inspect() );
            alert("Without Dan : "  + arr.without('Dan').inspect() );
         }
      </script>
   </head>

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

出力