NodeJS Flashcards
What is NodeJS?
NodeJS is a Javascript runtime that works for backend programming
NodeJS extends from an engine, what engine?
V8 Google engine, used to mainly in google chrome and NodeJs
Which language is V8 written in?
written in C++, to support Javascript.
How to execute Node from Cmd?
typing node
requiring a library that deals with file i/o
const fs = require(‘fs’)
creating a file synchronously with some content
fs.writeFileSync(‘filename.txt’, ‘filecontent’);
One example of development that is not associated with developing for server-side with NodeJS
Dealing with local files to process Building of production versions, ReactJs uses node indirectly for that, creating utility scripts in general.
What are the two ways of executing Node code?
by executing files (node (filename)) or REPL:
Read, Evaluate, Print, Loop, which is a way of executing code on the go in the command line, good playground.
Module to help with path concatenations
path, path.resolve(path1, path2)
The NodeJS event loop consists of 5 basic processes, the first step is
- Execution of timer functions (setTimer, setInterval, etc);
The NodeJS event loop consists of 5 basic processes, the second step is
- Execute pending (non-timer) callbacks from previous loops, such as I/O related callbacks and other events
The NodeJS event loop consists of 5 basic processes, the third step is
- Fetch new (non-timer) Event callbacks such as new connections and try to execute them right away, Or defer them to be executed in the next loop (2nd step)
The NodeJS event loop consists of 5 basic processes, the forth step is
- execute setImediate() callbacks, these are callbacks that execute always in the same loop, but always after all previous steps
The NodeJS event loop consists of 5 basic processes, the last step is
- Execute all ‘close’ event callbacks
What can happen when a long operation has to be executed by NodeJs?
It transfer the operation to the poll workers, which is carried with the work of deferring the process to another thread, the workers make sure this process happens automatically.