Dependency injection example in Javascript