NODE Flashcards
What is Node.js?
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?
read–eval–print loop / 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 by Ryan Dahl
What back end languages have you heard of?
Java , Ruby , Python, C++, PHP
What is a computer process?
is the instance of a computer program that is being executed by one or many threads.
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
alot
Why should a full stack Web developer know that computer processes exist?
You need to know how to make multiple process work together in order to form one application
What is the process object in a Node.js program?
its a global object that provides information about, and control over, the current Node.js process
How do you access the process object in a Node.js program?
As a global, it is always available to Node.js applications without using require(). It can also be explicitly accessed using require()
What is the data type of process.argv in Node.js?
an array
What is a JavaScript module?
a single .js file / js file containing code
What values are passed into a Node.js module’s local scope?
exports, require, module, __dirname, __filename
Give two examples of truly global variables in a Node.js program.
Process , console , setInterval, setTimeOut
variables available in every file
What is the purpose of module.exports in a Node.js module?
to be able to separate functions into their own files and make it easier for you to find what you are looking for
How do you import functionality into a Node.js module from another Node.js module?
by using module.exports on what you want to export and require where you need it
What is the JavaScript Event Loop?
it allows JS to offload its work onto the browser and gives the illusion of multithread / the order in which js is run
“The event loop job is to look at the stack and look at the task queue. If the stack is empty, it takes the first thing on the queue and pushed it on to the stack.”
What is different between “blocking” and “non-blocking” with respect to how code is executed?
Blocking stops JS from continuing to run the rest of the code and slows things down
Non blocking does not stop JS from continuing to run
What is a directory?
folders
What is a relative file path?
relative to a current directory / relative to where your starting from
What is an absolute file path?
where the root of the drive all the way to the path to the file/ the entire path
What module does Node.js include for manipulating the file system?
fs / filesystem module
What method is available in the Node.js fs module for writing data to a file?
fs.writeFile
Are file operations using the fs module synchronous or asynchronous?
asynchronous
What is a client?
service requester
What is a server?
providers of a resource or service / A server host runs one or more server programs, which share their resources with clients. / a server is more likely software on a computer
Which HTTP method does a browser issue to a web server when you visit a URL?
GET method
What are HTTP headers?
HTTP headers let the client and the server pass additional information with an HTTP request or response.
/ Key value pairs
What is on the first line of an HTTP response message?
Protocol version
Status Code
Status Text
What is on the first line of an HTTP request message?
header /
http method
Path
Version number
Is a body required for a valid HTTP message?
NO
What is NPM?
Worlds largest software registry. Used by developers to borrow and share packages. / Node Package Manager
What is a package?
bits of reusable code sometimes called modules
/ directory with 1 or more files
How can you create a package.json with npm?
npm init -y / npm init with -y flag
What is a dependency and how to you add one to a package?
Packages required by your application in production and they are dependent on these packages to work
What happens when you add a dependency to a package with npm?
you can now use the code from the dependency in your own code and its added to packages.json
How do you add express to your package dependencies?
npm install express
What Express application method starts the server and binds it to a network PORT?
express.listen(portNumber, callback) / listen method
How do you mount a middleware with an Express application?
use method of the app object
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
request object / response object
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
What is the significance of an HTTP request’s method?
to specify the desired action / to signify our intention for our given endpoint
What does the express.json() middleware do and when would you need it?
It parses incoming requests with JSON payloads and is based on body-parser. / Returns middleware that only parses JSON and only looks at requests where the Content-Type header matches the type option.
What is PostgreSQL and what are some alternative relational databases?
MySQL , SQL, Oracle / PostgreSQL is a powerful, free, open source Relational Database Management System (RDBMS). It is often cited as the most advanced open source database of its kind and is well-liked by the developer community for its robust feature set, standards compliance, and reliability.
What are some advantages of learning a relational database?
A quality of many relational databases is that they support good guarantees about data integrity. / works well with storing related data
What is one way to see if PostgreSQL is running?
pgweb / sudo service postgresql status / They can store and modify data in a way that makes data corruption as unlikely as possible.
What is a database schema?
A schema defines how the data in a relational database should be organized.
What is a table?
A table is a list of rows each having the same set of attributes
What is a row?
Hold all of the attributes for a single record of data
What is SQL and how is it different from languages like JavaScript?
Structured Query Language (SQL) is the primary way of interacting with relational databases. It is a powerful way of retrieving, creating, and manipulating data in a relational database. /
declarative programming language. In declarative languages, programmers describe the results they want and the programming environment comes up with its own plan for getting those results.
How do you retrieve specific columns from a database table?
select (followed by ) column names in ()
How do you filter rows based on some specific criteria?
by adding where “columnName”=’what you want’
What are the benefits of formatting your SQL?
You receive only what you want to get
How do you limit the number of rows returned in a result set?
limit followed by number
How do you retrieve all columns from a database table?
select *
How do you control the sort order of a result set?
order by clause
What are four comparison operators that can be used in a where clause?
equals / less than / greater than / not equal to
How do you add a row to a SQL table?
one first line you have `insert into “table name(in double quotes)” (list of columns) followed by values and in (the values)
What is a tuple?
the list of values
How do you get back the row being inserted into a table without a separate select statement?
by adding returning and * for all after the values
if you only want one value instead of * then “column name” / sometimes you dont want to get back something like passwords
How do you delete rows from a database table?
delete from “table” add where clause and returning
How do you accidentally delete all rows from a table?
delete from “table” / forget where clause
How do you add multiple rows to a SQL table at once?
by having multiple lines of values no values keyword in the following lines
What is a foreign key?
row in another table typically an id
How do you join two SQL tables?
select what column names then from what table and
Join to which table using what column name
How do you temporarily rename columns or tables in a SQL statement?
by aliasing column names / by using as keyword
What are some examples of aggregate functions?
sum(), count(), max(), min(), avg()
What is the purpose of a group by clause?
to set what you want to group it by.
What are the three states a Promise can be in?
Pending , Fulfilled , Rejected
How do you handle the fulfillment of a Promise?
with a .then / then method
How do you handle the rejection of a Promise?
with a catch / catch method
What is Webpack?
It’s a tool that lets you bundle your JavaScript applications (supporting both ESM and CommonJS), and it can be extended to support many different assets such as images, fonts and stylesheets.
How do you add a devDependency to a package?
npm install –save-dev package
What is an NPM script?
An npm script is a convenient way to bundle common shell commands for your project.
How do you execute Webpack with npm run?
by creating a script and npm run script
How are ES Modules different from CommonJS modules?
ES modules are more compact / the structure can be statically analyzed / their support for cyclic dependencies is better
/ ES use import CommonJS uses require
/ ES just uses export CJS uses module.exports
/Servers use CommonJS and browser use ES modules
What kind of modules can Webpack support?
ECMAScript (ES modules) / CommonJS / AMD / Assets / WebAssembly
What is the local __dirname variable in a Node.js module?
the path to the current directory / the directory where you are using __dirname
What does the join() method of Node’s path module do?
joins all path segments that are used as arguments / can join 2 path names dynamically
What does express.static() return?
returns the static files requested / function