
Emily K. answered 09/12/19
Web and iOS Programmer: JavaScript, Node, Swift, React, React Native
The biggest differentiating factor between a library and a framework is something called “Inversion of Control”.
When you’re using a library, you— the user— are typically in total control of what code is run, and when it runs. Thus, a library is essentially a collection of values and functions that you can choose to use as you see fit. For example, to do some math, transform data, draw into a canvas, etc.
A framework is the opposite. When using a framework, you— the user— don’t have control over most of the code execution. It’s more like filling in the blanks in a mad lib. The framework (often providing the skeleton for an application) is in charge of what code is run, and when it runs, and it asks you to provide any missing pieces as needed. You may be able to define what happens after the app starts, or how data should be fetched and stored, or which UI elements to display for a variety of circumstances, etc, but you are essentially playing the part of a library here.
Frameworks often contain and/or use libraries for their own convenience and for the user’s, but a library wouldn’t contain a framework.