Implement Inversion of Control

InstructorKent C. Dodds

Share this video with your friends

Send Tweet

Inversion of Control is a simple principle that can drastically improve your reusable code. In this lesson we'll go over the concept and you'll get an idea of how you can apply it for your own abstractions.

This is based on my blog post: Inversion of Control

This lesson is a Community Resource

A Community Resource means that it’s free to access for all. The instructor of this lesson requested it to be open to the public.

Daniel Deverell
Daniel Deverell
~ 11 months ago

Thanks for this. I will definitely be using inversion more in the future. Note to others: at the end of the video you probably want legCount set in the filterByLegCount function:

function filterByLegCount(array, legCount) {
  return filter(array, animal => animal.legs === legCount);
Chandrasekar Arunachalam
Chandrasekar Arunachalam
~ 11 months ago

Hello Kent,

Correct me if I'm wrong. To check undefined and null like this (element !== null && element !== undefined). Hope the following will work (element != null) this checks both undefined and null.