Node.js Flashcards
What is Node.js?
Node.js is an open-source, cross-platform JS runtime environment
Running a javascript code without being in the web broswer
What can Node.js be used for?
Used for server-side programming
primarily deployed for non-blocking, event-driven servers like traditional websites and back-end API services
Build a back-end, make command-line app, automated scripts in JS
What is a REPL?
A read-eval-print loop:
- it reads, evaluates, prints the result and then loop it by writting again in the next line
examples: console.logs() & browser dev console
When was Node.js created?
2009 - 2011
What back end languages have you heard of?
ruby, PHP, python, C++, java, C, C#, JS, perl, kotlin
What is the process object in a Node.js program?
control over information that is executing the current node
How do you access the process object in a Node.js program?
You can just reference it because it is a global object
What is the data type of process.argv in Node.js?
it is an array of strings
What is a JavaScript module?
It is a specific individual file
What values are passed into a Node.js module’s local scope?
__dirname & __filename & exports & module & require()
Give two examples of truly global variables in a Node.js program.
global & process & console object
What is the purpose of module.exports in a Node.js module?
Module.exports are the instructions that tell Node.js which bits of code (functions, objects, strings, etc) to export from a given file so that other files are allowed to access the exported code
To expose values to grab other files
How do you import functionality into a Node.js module from another Node.js module?
const variableName = require(‘fileName’)
Pulling information from another module
What is the JavaScript Event Loop?
part of the JS runtime environment that pushes asynchronous callbacks onto the call stack when the call stack is clear.
example: ajax, delay time
What is the difference between “blocking” and “non-blocking” with respect to how code is executed?
blocking: operations that block further execution until that op finishes - need to wait for other things to finish - anything that is sitting on the call stack
- For example: for-loop
non-blocking: code that doesn’t block execution - other things will execute while waiting for this code to be executed when there’s like a delay
- HTTP request,
What is a directory?
a special file that lists files and directories