Skip to content
markdown guide

In the context of which language? They usually mean slightly different things depending on the context


Ok then packages is not exactly a JavaScript concept, it's just the name that we give to the unit of distribution through npm/yarn.

Libraries or software that gets "packaged", distributed, indexed in a common website (the npm repository) and then can be installed from a client. npm or yarn are the package managers, the piece of software that you add as a dependency in your application is called a package.

JavaScript modules are instead a recent addition to the standard. They allow you to organize code in files and import them from one another, encapsulated in a namespace (instead of having everything global like in the old days). So you might have a module that contains common behavior and import it from multiple files. Es:

// time.js
export function now() {}
export function yesterday() {}

and then in your app you can import:

import { now, yesterday } from "./time.js"

I think this is the simplest explanation I can make, if you want to know more, this is a complete overview on how JavaScript modules work:

Classic DEV Post from Aug 16 '19

Powerlifting has made me a better developer. (Part 1: Interpersonally)

jebuscraisp profile image

πŸ‘‹ Hey reader.

Do you prefer sans serif over serif?

You can change your font preferences in the "misc" section of your settings. ❀️