angular - dependency injection
JavaScript
var Person = function(name, city) {
this.name = name;
this.city = city
}
function logger() {
// its tightly coupled
var john = new Person("Ram", "doon");
console.log(john);
}
logger();
// instead of creating objects inside the function we create it outside and inject into function
var johny2 = new Person("Shyam", "valley");
logger2(johny2);
function logger2(johny2) {
// its lightly coupled
console.log(johny2);
}