原型 - 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>

输出

prototype_array_processing.htm
广告
© . All rights reserved.