by kuni-toko-tachi · 12y ago · 0 comments
var prod_dependencies = {
obj0: require('obj0'),
obj1: require('obj1')
};
var test_dependencies = {
obj0: require('mockobj0'),
obj1: require('mockobj1')
};
var dependencies = test_dependencies;
some_func(dependencies.obj0,dependencies.obj1);
Javascript does not need Java-style dependency injection.
Javascript's configuration language JSON is valid Javascript.You are injecting dependencies into `some_func` by passing them in. See my response to kyllo below.
I think what you are arguing against is using further patterns to facilitate dependency injection, e.g. IOC containers, or what Angular uses (service locators).