[E] Practice JavaScript with Node

This is a collection of example programs that aims to learn you the basics of programming JavaScript with Node. You find them all in the teacher example repo.

Each example program has a README.md that explains the details of the program.

The basic idea is to read about the example program, try to execute it and then inspect the source code and learn from it.

Feel free to update and modify the example programs and you may also use the code as a base when working with the assignments.

The first example programs

You should already have checked these out when you first cloned the exercise repo. If so, just move on to the next section.

  1. src/main shows a hello world and how to write a main function or not.

  2. src/modules/es-import-class how to write a class in a separate file and include it.

  3. src/modules/es-import-module how to write a module in a separate file and include it.

The API

Use the built in Node API.

  1. src/builtins you can use the builtin objects in JavaScript as usual.

  2. src/input-output to read input data from the terminal and to output to the terminal.

  3. src/async-await how to work with asynchronous events and the difference when execution is out of sync.

Small applications

Smaller applications to learn how to program the structure from.

  1. src/cli a menu driven terminal application that plays a guessing game of "Guess My Number".

  2. src/cli-command-line-arguments to see how to use the command line arguments sent into the command while started.

HTML API

These examples are related to HTML APIs.

  1. src/fetch-api to see how the Fetch API can be used to make a HTTP request.

  2. src/fetch-api-with-module an extended Fetch API example that wrapped the fetch code into its own module and also includes POST, PUT, PATCH, DELETE requests.

Use external npm modules

This is how you can include and use external npm modules.

  1. src/console-table-printer to print out a datastructure into a table using colors and formats.

    1. src/console-table is doing the same but using the builtin console.table().
  2. src/html-parser to parse HTML code into a datastructure that can be analysed and parts from the document can be extracted.

Utilities and development tools

These might be handy when developing.

  1. src/json-server using an npm module to setup a fake JSON server for development.