Node/Express Flashcards
What does express.static() return?
It returns static files such as images, CSS files, and JavaScript files. It’s built-in middleware.
What is the local __dirname variable in a Node.js module?
Path to directory
What does the join() method of Node’s path module do?
Join the paths that are provided in arguments.
express.static(path.join(__dirname, ‘public’))
What does fetch() return?
It returns a promise.
What is the default request method used by fetch()?
Get method
How do you specify the request method (GET, POST, etc.) when calling fetch?
As an argument of fetch method
What is Node.js?
Program that allows JavaScript to be run outside of the browser or program written in C++ and embedded in JavaScript engine.
Definition - Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser
Outside of the browser - not interacting with Web UI (HTML, CSS) It’s backend programming interacting with databases.
What can Node.js be used for?
Backend applications and command-line programs.
What is a REPL?
take data from input and return something.
The Node.js Read-Eval-Print-Loop (REPL) is an interactive shell that processes Node.js expressions. The shell reads JavaScript code entered by users, evaluates the result of interpreting the line of code, prints the result to the user, and loops until the user signals to quit.
When was Node.js created?
2009 Ryan Dehl(was building a website and notice it didn’t scale)
What back end languages have you heard of?
Scripting languages : PHP, PYTHON, RUBY, PERL, JS, LUA System languages: C, C++, Rust, Zig. Byte Code languages Java, C#, Kotlin,
What is a computer process?
Instance of a running program
What is the process object in a Node.js program?
Global object that can be accessed without requiring it.
How do you access the process object in a Node.js program?
Process object is a global object and can be accessed inside any module without requiring it using keyword “process”.
What is the data type of process.argv in Node.js?
The data type of process.argv in Node.js is an array of strings.
Give two examples of truly global variables in a Node.js program.
process, url, console.log,
What is a JavaScript module?
It’s a file with a reusable code which we can use in different file.
What is the purpose of module.exports in a Node.js module?
Purpose of module.exports is to have access to code in different file.
How do you import functionality into a Node.js module from another Node.js module?
Using require function