
原型 - 列舉 include() 方法
此方法確定給定物件是否在列舉中,基於 == 比較運算子。這是 member() 方法的別名。
如果您需要檢查是否存在與給定謂詞匹配的元素,請改用 any() 方法。
語法
Iterator.include(object);
返回值
如果找到給定物件則返回真,否則返回假。
示例
<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>
輸出
prototype_enumerating.htm
廣告