返回到:Prototype – 枚举
此方法是对 collect() 方法的常见用例的优化。为所有元素获取相同的属性。
语法
Iterator.pluck(propertyName);
返回值
返回属性值数组。
例子
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
var arr = ['world', 'this', 'is', 'nice'].pluck('length');
alert("Test 1 : " + arr.inspect() );
// Returns [5, 4, 2, 4]
}
</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/8586.html
支付宝
微信