MooTools framework "Three"-array: Main Method Test Example

Source: Internet
Author: User

<%@ Page language= "C #" autoeventwireup= "true" codefile= "Default.aspx.cs" inherits= "_default"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title>mootools--Native:Array</title>
<script language= "javascript" type= "Text/javascript" src= "Mootools-1.2-core-jm.js" ></script>
<script language= "javascript" type= "Text/javascript" >
{
foreach Usage One
var arr = [1,2,3,4,5,6];
Arr.foreach (function (e) {
Alert (e);
});
foreach Usage Two
var arr = [1,2,3,4,5,6];
var obj = "hello!";
Arr.foreach (function (e) {
Alert (e+ '-' +this); This here refers to the Obj object that follows
},obj);
foreach Usage Three
function Putelt (element, index, array) {//Output to page
document.write ("pos [" + Index + "] in Array (" + array + ") is" + element + ' <br> ');
}
[2, 5, 9].foreach (Putelt);

Filter method
var result = [1,2,3,4,5].filter (function (e) {
return e > 3;
});
alert (result); The result is 4,5

Map method
var result = [1,2,3,4,5].map (function (e) {
return e + ' px ';
});
alert (result);
Some method
var result = [1,2,3,4,5].every (function (e) {
return e > 3;
});
alert (result); Returns True

Extend method
var a = [1,2,3,4];
var b = [1,11,12];
A.extend (b);
alert (a);
}
</script>

<body>
<form id= "Form1" runat= "Server" >
<div>
</div>
</form>
</body>

Article Source: http://www.cnblogs.com/ziyiFly/category/153865.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.