Recap

Junior Year, page 11 of 11. A one-minute read.

  • Modules split code into separate files. Each module has its own scope.
  • export shares things from a module. import { name } from "./file.js" brings them in. Each module can have one export default, imported without braces.
  • In the browser, use <script type="module">, served from a web server (like Live Server).
  • Node.js runs JavaScript outside the browser, with extra powers: files, servers, databases, command-line tools.
  • Enable import/export in Node with "type": "module" in package.json (or .mjs files). Older code uses require (CommonJS).
  • node:fs/promises gives you readFile and writeFile. process.argv.slice(2) gives you command-line arguments (as strings).
  • npm installs packages from the npm registry. npm init -y creates package.json. npm install name adds a dependency to node_modules. Never share or edit node_modules.
  • npm scripts in package.json create shortcut commands like npm start and npm test.
  • Automated tests check your code for you. Node has a built-in runner: node --test with node:test and node:assert.
  • The pro toolbox: Git/GitHub, Prettier, ESLint, TypeScript, frameworks (React, Vue, Svelte, Angular), build tools (Vite) and hosting (GitHub Pages, Netlify, Vercel).

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.

Start learning