> For the complete documentation index, see [llms.txt](https://ret2basic.gitbook.io/ctfnote/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ret2basic.gitbook.io/ctfnote/computer-science/html-css-javascript-and-react/javascript/modules.md).

# Modules

## Node Imports

Import Node built-in modules or locally installed third-part module:

```javascript
// These modules are built in to Node
const fs = require("fs");     // The built-in filesystem module
const http = require("http"); // The built-in HTTP module

// The Express HTTP server framework is a third-party module.
// It is not part of Node but has been installed locally.
const express = require("express");
```

Import your own code:

```javascript
const stats = require('./stats.js');
const BitSet = require('./utils/bitset.js');
```

You can either import everything:

```javascript
// Import the entire stats object, with all of its functions
const stats = require('./stats.js');

// We've got more functions than we need, but they're neatly
// organized into a convenient "stats" namespace.
let average = stats.mean(data);
```

Or import only a function:

```javascript
// Alternatively, we can use idiomatic destructuring assignment to import
// exactly the functions we want directly into the local namespace:
const { stddev } = require('./stats.js');

// This is nice and succinct, though we lose a bit of context
// without the 'stats' prefix as a namespace  for the stddev() function.\
let sd = stddev(data);
```
