Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript React Basics (retired) First Steps in React Why React

What Exactly is "Inversion Control"?

I was doing some research to try and understand the similarities and differences between React, Angular, and Vue and stumbled upon the contrast that React is a library whereas Angular and Vue are both frameworks, and that the key difference between a library and a framework is that a framework uses something called "inversion control". I can't seem to grasp this concept. My question is: what exactly is "inversion control"?

1 Answer

Ari Misha
Ari Misha
19,323 Points

Hello there! Inversion of Control (IoC) is much broader, which basically means Control (forget about the Inversion part). Dependency Injection(DI) is a subset of IoC. Lemme present you an example:

Suppose you bought a new expensive 4K LED TV, right? So while unboxing your new TV, you mishandle the TV and the screen breaks. Now, you're thinking of two options: let's buy a new TV of almost same specs 'coz I'm hella rich and I like spending money, and the second option is: I'm a cheapass so I want the same TV with the same 4k screen., right?

The first part represents the concept of the IoC and the latter represents the*DI. In software programming words, **IoC* is like giving control to the container to get an instance of the object, means instead of you are creating an object using the new operator, let the container do that for you.

I hope it helps!

~ Ari