What you’ll learn
- Why big programs are split into modules
exportandimport- Using modules in the browser
- What Node.js can do that browsers can't
- Reading and writing files with Node
- Command-line arguments with
process.argv - npm,
package.jsonand installing packages - Testing your code with Node's built-in test runner
- A tour of the professional developer's toolbox
The pages
Eleven pages, about 17 minutes.
- Why Modules? Imagine a kitchen with no cupboards, drawers or shelves. Every pot, spoon, plate, spice jar and tea towel is just…
- Exporting and Importing Let's make a module. Create a file called math-utils.js. The keyword export in front of a variable or function means…
- Modules in the Browser To use modules in a web page, add type="module" to your script tag. Module scripts behave a little differently from…
- Node.js: JavaScript Outside the Browser You've been using Node.js since Kindergarten to run JavaScript files. But Node can do much more than print to the…
- Reading and Writing Files Node comes with a bunch of built-in modules. You import them using a name that starts with node:. The one you'll use…
- Command-Line Arguments When you run a Node program, you can pass extra words after the file name. Node puts them in an array called…
- npm: The World's Biggest Toolbox Here's one of the best things about JavaScript: you almost never have to build everything yourself. Developers all…
- Testing Your Code How do you know your code works? So far, you've been running it and eyeballing the output. That's fine for small…
- Mini Project: The Expense Tracker CLI Let's build a real command-line tool that tracks your spending and saves it to a file. Make a new folder, run npm init…
- The Professional Developer's Toolbox You now know JavaScript itself. But professional developers also use a set of tools around the language. You don't…
- Recap The key ideas of Junior Year, JavaScript modules and Node.js, on one page. Modules split code into separate files…
Reading is step one
CurlyScript turns these notes into a game: short questions, an explanation after every answer, and a test at the end of each grade. Free, with nothing to sign up for.