JavaScript????????????????
???????????? ???????[ 2015/8/11 10:55:05 ] ????????WEB???? ???????
???????????????У?Array.prototype.slice.call(arguments?? 0)?????????arguments????????????????????顣??????????????????????????????????????????????????????????????????д???Σ???????????????????????????????????????е??????????
????????(reflection)????
???????????????е?????????(reflection)????????????????й????У?????????????????????????????JavaScript?У????????????????????????????????????????????????doSomething??????????????doSomething.toString()???????????????????????:
????"function (service?? router?? other) {
????var s = service();
????var r = router();
????}"
???????????????????????????????????????????????????????????????????????????????????????AngularJS???????????????????????AngularJS??????У?????????????????????????
????/^functions*[^(]*(s*([^)]*))/m
????????????resolve????????????????????
????resolve: function() {
????var func?? deps?? scope?? args = []?? self = this;
????func = arguments[0];
????deps = func.toString().match(/^functions*[^(]*(s*([^)]*))/m)[1].replace(/ /g?? '').split('??');
????scope = arguments[1] || {};
????return function() {
????var a = Array.prototype.slice.call(arguments?? 0);
????for(var i=0; i<deps.length; i++) {
????var d = deps[i];
????args.push(self.dependencies[d] && d != '' ? self.dependencies[d] : a.shift());
????}
????func.apply(scope || {}?? args);
????}
????}
????????????????????????????????????????????????????????????
????["function (service?? router?? other)"?? "service?? router?? other"]
?????????????????????????????????????????????????з?????????????????deps???顣?????????????????????????
????var a = Array.prototype.slice.call(arguments?? 0);
????...
????args.push(self.dependencies[d] && d != '' ? self.dependencies[d] : a.shift());
???????????????У????????????????????????????????????????????????????????????????arguments?????л????????????????????飬??????shift???????????undefined???????????????????????????°汾??injector???????????????
????var doSomething = injector.resolve(function(service?? other?? router) {
????expect(service().name).to.be('Service');
????expect(router().name).to.be('Router');
????expect(other).to.be('Other');
????});
????doSomething("Other");
???????????????У?????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????У????????????????仯??????????????????????????磺
????var doSomething=function(e??t??n){var r=e();var i=t()}
?????????????????????????????AngularJS????????
????var doSomething = injector.resolve(['service'?? 'router'?? function(service?? router) {
????}]);
?????????????????AMD??????????????????????????????????????????????????????????????
????var injector = {
????dependencies: {}??
????register: function(key?? value) {
????this.dependencies[key] = value;
????}??
????resolve: function() {
????var func?? deps?? scope?? args = []?? self = this;
????if(typeof arguments[0] === 'string') {
????func = arguments[1];
????deps = arguments[0].replace(/ /g?? '').split('??');
????scope = arguments[2] || {};
????} else {
????func = arguments[0];
????deps = func.toString().match(/^functions*[^(]*(s*([^)]*))/m)[1].replace(/ /g?? '').split('??');
????scope = arguments[1] || {};
????}
????return function() {
????var a = Array.prototype.slice.call(arguments?? 0);
????for(var i=0; i<deps.length; i++) {
????var d = deps[i];
????args.push(self.dependencies[d] && d != '' ? self.dependencies[d] : a.shift());
????}
????func.apply(scope || {}?? args);
????}
????}
????}
??????????汾??resolve?????????????????????????????????????β??????
????var doSomething = injector.resolve('router????service'?? function(a?? b?? c) {
????expect(a().name).to.be('Router');
????expect(b).to.be('Other');
????expect(c().name).to.be('Service');
????});
????doSomething("Other");
???????????????????????????????У?????????????????????Other?????????????????????????????????
????????
????????????????У?????????????JavaScript??????????????????????????????????????????????????????д???????????????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
JavaScript????????????JavaScript???????????????????????????Prepack?JavaScript???????????2017???????JavaScript??????????JavaScript??????????????????Node.js?п?JavaScript????????????????????????JavaScript??????JavaScript ??????β??????????????????JavaScript?????????????JavaScript???????????this???????????????????????JavaScript????????????JavaScript??Java??PHP????????д???????????Node?????????JavaScript????JavaScript ????????vs????vs???????Javascript??????????С?????????????????JavaScript?????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????