返回到:Prototype – 数组处理
此方法生成数组的无重复版本。如果没有找到重复项,则返回原始数组。
语法
array.uniq();
返回值
返回一个没有重复元素的新数组。
例子
<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("Old Array : " + arr.inspect() );
alert("New Array : " + arr.uniq().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 – 数组处理
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8756.html
支付宝
微信