返回到:Prototype – 枚举
此方法是对 each() 或 collect() 方法的常见用例的优化。为所有元素调用具有相同潜在参数的相同方法。
语法
Iterator.invoke(methodName[, arg...]);
返回值
返回方法调用的结果。
例子
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
alert(['hello', 'world', 'cool!'].invoke('toUpperCase') );
// Returns ['HELLO', 'WORLD', 'COOL!'];
alert(['hello', 'world', 'cool!'].invoke('substring', 0, 3));
// Returns ['hel', 'wor', 'coo']
}
</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/8603.html
支付宝
微信