码迷,mamicode.com
首页 > Web开发 > 详细

js题集20

时间:2017-08-08 12:26:18      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:func   his   prot   enc   ram   代码   bsp   param   injector   

1.实现如下代码功能

var deps = {

  ‘dep1‘: function () {return ‘this is dep1‘;},

  ‘dep2‘: function () {return ‘this is dep2‘;},

  ‘dep3‘: function () {return ‘this is dep3‘;},

  ‘dep4‘: function () {return ‘this is dep4‘;}

};

 

var di = new DI(deps);

 

var myFunc = di.inject(function (dep3, dep1, dep2) {

  return [dep1(), dep2(), dep3()].join(‘ -> ‘);

});

 

myFunc();// ‘this is dep1 -> this is dep2 -> this is dep3‘);

 

=============your code==============

/**

 * Constructor DependencyInjector

 * @param {Object} - object with dependencies

 */

var DI = function (dependency) {

  this.dependency = dependency;

};

 

// Should return new function with resolved dependencies

DI.prototype.inject = function (func) {

  // Your code goes here

}

js题集20

标签:func   his   prot   enc   ram   代码   bsp   param   injector   

原文地址:http://www.cnblogs.com/tong24/p/7305816.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!