You should be able to:
- Explain the purpose of Node
- Use
module.exports
andrequire
to create modular applications - Describe what
npm
is and its purpose - Explain asynchronicity in JavaScript (its "non-blocking" nature)
- Node is a runtime environment that has the ability to run a V8 engine on environments other than the browser (e.g. operating systems, servers, etc.).
- It's an object that tells Node which pieces of code to export from a given file so that other files are able to access the exported code.
- It's a built-in function that allows a file to include modules that exist in separate files. The basic functionality of
require
is that it reads a JavaScript file, executes the file, and then proceeds to return theexports
object.
fs
(Node: File system)http
(Node: HTTP)path
(Node: Path)curl
☑️ (curl)
console.log('Hello')
setTimeout(() => { console.log('a new') }, 5000)
console.log('World')
Log | 1st | 2nd | 3rd |
---|---|---|---|
Hello | ☑️ | ||
a new | ☑️ | ||
World | ☑️ |
const cool = () => {
console.log('Running inside the cool function')
setTimeout(
() => {
console.log('Timing out inside the cool function')
},
3000
)
}
setTimeout(
() => {
console.log('I am not in any function')
},
3000
)
cool()
console.log('End of File')
Log | 1st | 2nd | 3rd | 4th |
---|---|---|---|---|
Running inside the cool function | ☑️ | |||
Timing out inside the cool function | ☑️ | |||
I am not in any function | ☑️ | |||
End of File | ☑️ |