Javascript browser judges binding event arguments to convert array traversal _ javascript skills

Source: Internet
Author: User
Javascript browser determines the function of converting the arguments to array traversal. The Code is as follows:


Var $ d = document;

Function $ I (s) {return $ d. getElementById (s );}
Var _ jsc = {}
_ Jsc. client = (function (){
Var t = {};
Var B = navigator. userAgent. toLowerCase ();
T. isOpera = (B. indexOf ('Opera ')>-1)
T. isIE = (B. indexOf ('msie ')>-1)
T. isFF = (! T. isOpera &&! T. isIE & B. indexOf ("firefox")>-1 );
Return t;

})()
_ Jsc. util = (function (){
Var t = {}
T. addEvent = function (o, e, f ){
If (_ jsc. client. isIE ){
O. attachEvent ("on" + e, f)
} Else {
O. addEventListener (e, f, fasle );
}
Return true
}
Return t;
})();
// Window. onload = function () {_ jsc. util. addEvent (document, "click", showMsg ("z", "d "))}
_ Jsc. util. addEvent (document, "click", function () {showMsg ("a", "B ")})

Function showMsg ()
{
// Alert (typeof arguments)
// Var dd = [arguments [0], arguments [1]
// Var o = {a: 'A', B: 'bb', c: 'cc '};
// Var o = {};
O = arguments
O = Array. prototype. slice. call (arguments, 0 );
For (var p in o)
{
Alert (o [p]);
}

All attributes of the loop object:
Script
Var o = {a: 'A', B: 'bb', c: 'cc '};
For (var p in o)
{
Alert (eval ("o." + p ));
}
Script

All elements of the loop array:

Script
Var arr = ['11', '22', '33'];
For (var I in arr)
{
Alert (arr [I]);
}
Script

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.