Prototype - 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>单击按钮查看结果。</p>
      <br />
      <br />
      <input type = "button" value = "Result" onclick = "showResult();"/>
   </body>
</html>

输出

prototype_array_processing.html