zoukankan      html  css  js  c++  java
  • js 解决函数加载的问题

    var queue = function(funcs, scope) {
            (function next() {
                  if(funcs.length > 0) {
                      funcs.shift().apply(scope || {}, [next].concat(Array.prototype.slice.call(arguments, 0)));
                  }
            })();
        };
        
        var obj = {
            value: null
        };
        
        queue([
            function(callback) {
                var self = this;
                setTimeout(function() {
                    self.value = 10;
                    callback(20);
                }, 200);
            },
            function(callback, add) {
                console.log(this.value + add);
                callback();
        },
            function() {
                console.log(obj.value);
            }
        ], obj);
  • 相关阅读:
    《人月神话》阅读笔记3
    团队冲刺0110
    团队冲刺0109
    团队冲刺0108
    团队冲刺0107
    团队冲刺0106
    团队冲刺0105
    团队冲刺010304
    团队冲刺0102
    团队冲刺0101
  • 原文地址:https://www.cnblogs.com/shidengyun/p/5406988.html
Copyright © 2011-2022 走看看