Concepts
Dependency injection
Design technique supplying an object or function dependency from outside its consumer, allowing controlled substitution and test isolation.
Formal Syntax & Structure
javascript syntaxjavascript
new Service(dependency)Working Example
Example Snippetjavascript
class Report{constructor(format){this.format=format;}run(n){return this.format(n);}}console.log(new Report(n=>"N="+n).run(4));