Node.js Flashcards
What is Node.js?
program that allows JavaScript to be run outside of a web browser
What can Node.js be used for?
build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform.
write web servers, mobile apps, general programming
What is a REPL?
read–eval–print loop (REPL), also termed an interactive toplevel or language shell, is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user
REPL stands for Read Evaluate Print Loop, and it is a programming language environment (basically a console window) that takes single expression as user input and returns the result back to the console after execution. system that listens for typing in command and processes it
What is a computer process?
the instance of a computer program that is being executed by one or many threads.
environment in which program runs and executing code
Why should a full stack Web developer know that computer processes exist?
to see which process is running the server ,database and understanding how the system works together
What is the process object in a Node.js program?
a global that provides information about, and control over, the current Node.js process
How do you access the process object in a Node.js program?
const process = require(‘process’);
call the variable
in a node.js need to open it through node terminal and the js file
What is the data type of process.argv in Node.js?
array of strings
What is a JavaScript module?
A .js file that has functions and variables that can be exported and used
What values are passed into a Node.js module’s local scope?
Exports, require, module, __filename,__dirname
the variables accessible in the local scope of that specific module
Give two examples of truly global variables in a Node.js program.
__dirname, __filename, exports, module, require()
global, process, console
What is the purpose of module.exports in a Node.js module?
To allow using code from a module in another module
Way to expose things inside one module into another module
How do you import functionality into a Node.js module from another Node.js module?
Module.exports = functionName in the exporting module
const varName = require(‘./jsFileName); in the import module
What is the JavaScript Event Loop?
The functionality in javascript that looks at the stack and if its empty, take the first thing on the queue and push onto the stack
mechanism for doing asynchronous code to run later or defer
way the system manages execution from taking code off the queue and running it, looping this system
What is different between “blocking” and “non-blocking” with respect to how code is executed?
Blocking prevents any code from running until the current code is finished, synchronous
event loop takes code off the queue, and the system is blocked while its running. if its non blocking, put another task on the queue so it runs right after
nonblocking - running things asynchronously, deferred until after