Functions are great to organize code within one file, or a few files.

But what can you do when your files structure starts to become too crowded?

You reach for packages.

Packages are essentially similar to functions, except instead of abstracting away a piece of functionality to reuse in your program, you can remove them from your program altogether, and place them outside of it.

Multiple programs can now reuse a tiny functionality (or a bigger functionality) and you only have to maintain it in one place.

In JavaScript land, packages are commonly published to npm.

Importing a package is very easy, and it’s also common to create packages for all sort of things, even very small ones.

Other languages and communities have similar package repositories and ecosystems. Python has pip, for example.

It’s great when a language ecosystem is built around Open Source. JavaScript in particular is heavily rooted towards Open Source, and you can easily find free to use packages for nearly everything.


Go to the next lesson