Node.js Flashcards
What is Node.js?
Node.js is a program that allows JavaScript to be run outside of a web browser.
What can Node.js be used for?
It is commonly used to build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform.
What is a REPL?
A 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; a program written in a REPL environment is executed piecewise.
When was Node.js created?
May 27, 2009
What is the process object in a Node.js program?
Is a global variable that provides information about, and control over, the current Node.js process.
The process object is an instance of EventEmitter.
How do you access the process object in a Node.js program?
Call it as you would any other object in JS, it’s global
What is the data type of process.argv in Node.js?
array or strings
What does proces.argv do?
The process.argv property returns an array containing the command line arguments passed when the Node.js process was launched.
$ node process-args.js one two=three four
0: /usr/local/bin/node
1: /Users/mjr/work/node/process-args.js
2: one
3: two=three
4: four
What is a JavaScript module?
each separate js file
What values are passed into a Node.js module’s local scope?
(function(exports, require, module, __filename, __dirname) {
// Module code actually lives in here
});
Give two examples of truly global variables in a Node.js program.
console
process
What is the purpose of module.exports in a Node.js module?
Makes things available to other modules in your node. js program
How do you import functionality into a Node.js module from another Node.js module?
call the require function, pass in a relative path, and assign its return value to a variable
What is the JavaScript Event Loop?
The event loop looks at the stack and the task queue. I the stack is empty, it pushed it from the task queue to the stack, which effectively runs it.
What is different between “blocking” and “non-blocking” with respect to how code is executed?
blocking code is occupying the call stack.