Looking into Dependency Injection in JavaScript, as with Angular, I decided that true DI was overkill for my medium sized project, so I worked on a simpler way to organize my project and implement Inversion of Control. I felt interfaces aren't really worth the extra syntax since JavaScript has so few data types to deal with, and it's really easy to type check in JS without the help of interfaces. And I felt that it was unnecessary to define different variations of services (factories, etc), and I instead treat every element as a simple service, which can depend on any other service(s). I'm pretty sure the result would not be called DI. So what would I call this pattern? And can this be considered a form of IoC?var Directory = function() {  this.directories = {};  this.items = {};}var root = new Directory();//File projects/my-project-1/libraries/depends.jsvar Service = function(name, dependencies, func) {  this.dependencyCollection = [];  this.func;  for (var x = 0; x < dependencies.length; x++) {    var nameSegments = dependencies[x].split(' / ');    var service = root;    var servicePlaceholder = service;    for (var i = 0; i < nameSegments.length; i++) {      var segment = nameSegments[i];      if (i === nameSegments.length - 1) {        if (servicePlaceholder.items[segment]) {          this.dependencyCollection.push(servicePlaceholder.items[segment]);        } else {          throw 'Dependent item missing: ' + JSON.stringify(servicePlaceholder.items, null, 3) + ' (' + dependencies + :  + segment + ')';        }      } else if (servicePlaceholder.directories[segment]) {        servicePlaceholder = servicePlaceholder.directories[segment];      } else {        throw 'Dependent directory missing: ' + JSON.stringify(servicePlaceholder.directories, null, 3) + ' (' + segment + ')';      }    }  }  var directory = root;  var directoryPlaceholder = directory;  var nameSegments = name.split(' / ');  for (var i = 0; i < nameSegments.length; i++) {    var segment = nameSegments[i];    if (i === nameSegments.length - 1) {      directoryPlaceholder.items[segment] = func.apply(null, this.dependencyCollection);      this.init = function() {        func.apply(null, this.dependencyCollection);      }    } else {      if (directoryPlaceholder.directories[segment]) {        directoryPlaceholder = directoryPlaceholder.directories[segment];      } else {        directoryPlaceholder.directories[segment] = new Directory();        directoryPlaceholder = directoryPlaceholder.directories[segment];      }    }  }}//File: projects/my-project-1/js/selectors/button-1.jsvar button = new Service('selectors / button-1', [], function() {  return $('.button');});//File: projects/my-project-1/js/selectors/body.jsvar body = new Service('selectors / body', [], function() {  return $('body');});//File: projects/my-project-1/js/handlers/handler-1.jsvar handler = new Service('handlers / handler-1', ['selectors / button-1', 'selectors / body'], function(button, body) {  button.on('click', function() {    body.css({      'background-color': 'green'    });  });}).init();
What is this deviation from Dependency Injection called?
javascript
It's called service locator.  It's not dependency injection at all.  This is an elaborate key value store where the keys use / as a delimiter.  I don't see how this helps inject dependencies. It hides dependencies. This is a place to stash global objects. 