js题集20

2021-06-08 22:04

阅读:609

标签: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


评论


亲,登录后才可以留言!