Prototype Tool Function Learning _prototype

Source: Internet
Author: User
Tags hash
$H is a convenient way to establish a hash object, specific reference to the hash object "Prototype Learning--hash Object"
$R is the easy way to resume Objectrange object, about Objectrange object specific reference "Prototype Learning--objectrange Object"
Try.these:
Accepts a arbitrary number of functions and returns the result of the ' the ' of the ' the ' of the ' the ' the ' the ' doesn ' t throw '.
Copy Code code as follows:

is to use a loop nested Try...catch to complete this tool function.
var Try = {
These:function () {
var returnvalue;
for (var i = 0, length = arguments.length i < length; i++) {
var lambda = arguments[i];
try {
returnvalue = lambda ();
Break
catch (e) {}
}
Return returnvalue;
}
};

Look at an example (different browsers have different ways to create XMLHttpRequest):
Copy Code code as follows:

Gettransport:function () {
Return Try.these (
function () {return new XMLHttpRequest ()},
function () {return new ActiveXObject (' Msxml2.xmlhttp ')},
function () {return new ActiveXObject (' Microsoft.XMLHTTP ')
} ) || False }

Document.getelementsbyclassname ():
The name of this method probably guesses the purpose of this method. But this method is marked in 1.6
It's deprecated. Replaced by the $$ and Eelement.select methods, the two methods are discussed later.

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.