FIS源码解析之use

(function () {
        var l = {};
        function h(s, r) {
            if (s instanceof Array) {
                var q = 0, p = 0;
                for (q, p = s.length; q < p; q++) {
                    if (r.call(s[q], s[q], q) === false) {
                        return
                        /*call:调用一个对象的一个方法,以另一个对象替换当前对象。  
                        此时r被s[q]替换,然而产生了一个生的对象s[q],即r成为了附本
                        对象的函数为s[q]=r(s[q],q)
                        r(s[q],q)对应的原文为function (s, t),即s=s[q],t=q*/
                    }
                }
            }
        }
        l.use = function (r, q) {
            if (typeof r === "string") {//参数只接受字符串格式
                r = [r]
            }
            h(r, function (s, t) {//此处的匿名函数用于生成call附本
                alert(s);   //s='Sn'
                alert(t);   //t=0        
            })
        }
        window.l = l;

    })();
   l.use("Sn", function (X) { }, []);

posted @ 2013-04-03 16:37  microsoftzhcn  阅读(221)  评论(0编辑  收藏  举报