返回到:Prototype – 数组处理
此方法返回数组的平面(一维)版本。嵌套数组以内联方式递归注入。
这在处理递归收集算法的结果时非常有用。
语法
array.flatten();
返回值
返回平面(一维)数组。
例子
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
var arr =['frank',['bob','lisa'],['jill',['tom','sally']]];
// Now flatten this array.
var newArr = arr.flatten();
newArr.each(function(item) {
alert(item);
});
}
</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/8786.html
支付宝
微信