DEV Community

Discussion on: Understanding Dependency Injection in JavaScript

Collapse
 
jurijzahn8019 profile image
Jurij Zahn • Edited

I agree with the Author. Js is highly dynamic and powerful so I think it does not really need any kind of IOC. If I pick up the example I will probably end up with something like this:

function whatDoesMyPetSay < T extends { speak: () => string; }>(pet: T): string {
pet.speak();
}

🙂

Collapse
 
_mohanmurali profile image
Mohan Murali

Yes, I agree, You can do it in many ways in JavaScript.