NODE Flashcards

1
Q

What is Node.js?

A

a program that allows JavaScript to be run outside of a web browser.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What can Node.js be used for?

A

It is commonly used to build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a REPL?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When was Node.js created?

A

May 27, 2009 by Ryan Dahl

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What back end languages have you heard of?

A

Java , Ruby , Python, C++, PHP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a computer process?

A

is the instance of a computer program that is being executed by one or many threads.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?

A

alot

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why should a full stack Web developer know that computer processes exist?

A

You need to know how to make multiple process work together in order to form one application

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the process object in a Node.js program?

A

its a global object that provides information about, and control over, the current Node.js process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you access the process object in a Node.js program?

A

As a global, it is always available to Node.js applications without using require(). It can also be explicitly accessed using require()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the data type of process.argv in Node.js?

A

an array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a JavaScript module?

A

a single .js file / js file containing code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What values are passed into a Node.js module’s local scope?

A

exports, require, module, __dirname, __filename

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Give two examples of truly global variables in a Node.js program.

A

Process , console , setInterval, setTimeOut

variables available in every file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the purpose of module.exports in a Node.js module?

A

to be able to separate functions into their own files and make it easier for you to find what you are looking for

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you import functionality into a Node.js module from another Node.js module?

A

by using module.exports on what you want to export and require where you need it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the JavaScript Event Loop?

A

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.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is different between “blocking” and “non-blocking” with respect to how code is executed?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is a directory?

A

folders

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is a relative file path?

A

relative to a current directory / relative to where your starting from

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is an absolute file path?

A

where the root of the drive all the way to the path to the file/ the entire path

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What module does Node.js include for manipulating the file system?

A

fs / filesystem module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What method is available in the Node.js fs module for writing data to a file?

A

fs.writeFile

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Are file operations using the fs module synchronous or asynchronous?

A

asynchronous

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What is a client?

A

service requester

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What is a server?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Which HTTP method does a browser issue to a web server when you visit a URL?

A

GET method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What are HTTP headers?

A

HTTP headers let the client and the server pass additional information with an HTTP request or response.
/ Key value pairs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What is on the first line of an HTTP response message?

A

Protocol version
Status Code
Status Text

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What is on the first line of an HTTP request message?

A

header /
http method
Path
Version number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Is a body required for a valid HTTP message?

A

NO

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

What is NPM?

A

Worlds largest software registry. Used by developers to borrow and share packages. / Node Package Manager

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

What is a package?

A

bits of reusable code sometimes called modules

/ directory with 1 or more files

34
Q

How can you create a package.json with npm?

A

npm init -y / npm init with -y flag

35
Q

What is a dependency and how to you add one to a package?

A

Packages required by your application in production and they are dependent on these packages to work

36
Q

What happens when you add a dependency to a package with npm?

A

you can now use the code from the dependency in your own code and its added to packages.json

37
Q

How do you add express to your package dependencies?

A

npm install express

38
Q

What Express application method starts the server and binds it to a network PORT?

A

express.listen(portNumber, callback) / listen method

39
Q

How do you mount a middleware with an Express application?

A

use method of the app object

40
Q

Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?

A

request object / response object

41
Q

What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?

A

application/json

42
Q

What is the significance of an HTTP request’s method?

A

to specify the desired action / to signify our intention for our given endpoint

43
Q

What does the express.json() middleware do and when would you need it?

A

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.

44
Q

What is PostgreSQL and what are some alternative relational databases?

A

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.

45
Q

What are some advantages of learning a relational database?

A

A quality of many relational databases is that they support good guarantees about data integrity. / works well with storing related data

46
Q

What is one way to see if PostgreSQL is running?

A

pgweb / sudo service postgresql status / They can store and modify data in a way that makes data corruption as unlikely as possible.

47
Q

What is a database schema?

A

A schema defines how the data in a relational database should be organized.

48
Q

What is a table?

A

A table is a list of rows each having the same set of attributes

49
Q

What is a row?

A

Hold all of the attributes for a single record of data

50
Q

What is SQL and how is it different from languages like JavaScript?

A

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.

51
Q

How do you retrieve specific columns from a database table?

A

select (followed by ) column names in ()

52
Q

How do you filter rows based on some specific criteria?

A

by adding where “columnName”=’what you want’

53
Q

What are the benefits of formatting your SQL?

A

You receive only what you want to get

54
Q

How do you limit the number of rows returned in a result set?

A

limit followed by number

55
Q

How do you retrieve all columns from a database table?

A

select *

56
Q

How do you control the sort order of a result set?

A

order by clause

57
Q

What are four comparison operators that can be used in a where clause?

A

equals / less than / greater than / not equal to

58
Q

How do you add a row to a SQL table?

A

one first line you have `insert into “table name(in double quotes)” (list of columns) followed by values and in (the values)

59
Q

What is a tuple?

A

the list of values

60
Q

How do you get back the row being inserted into a table without a separate select statement?

A

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

61
Q

How do you delete rows from a database table?

A

delete from “table” add where clause and returning

62
Q

How do you accidentally delete all rows from a table?

A

delete from “table” / forget where clause

63
Q

How do you add multiple rows to a SQL table at once?

A

by having multiple lines of values no values keyword in the following lines

64
Q

What is a foreign key?

A

row in another table typically an id

65
Q

How do you join two SQL tables?

A

select what column names then from what table and

Join to which table using what column name

66
Q

How do you temporarily rename columns or tables in a SQL statement?

A

by aliasing column names / by using as keyword

67
Q

What are some examples of aggregate functions?

A

sum(), count(), max(), min(), avg()

68
Q

What is the purpose of a group by clause?

A

to set what you want to group it by.

69
Q

What are the three states a Promise can be in?

A

Pending , Fulfilled , Rejected

70
Q

How do you handle the fulfillment of a Promise?

A

with a .then / then method

71
Q

How do you handle the rejection of a Promise?

A

with a catch / catch method

72
Q

What is Webpack?

A

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.

73
Q

How do you add a devDependency to a package?

A

npm install –save-dev package

74
Q

What is an NPM script?

A

An npm script is a convenient way to bundle common shell commands for your project.

75
Q

How do you execute Webpack with npm run?

A

by creating a script and npm run script

76
Q

How are ES Modules different from CommonJS modules?

A

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

77
Q

What kind of modules can Webpack support?

A

ECMAScript (ES modules) / CommonJS / AMD / Assets / WebAssembly

78
Q

What is the local __dirname variable in a Node.js module?

A

the path to the current directory / the directory where you are using __dirname

79
Q

What does the join() method of Node’s path module do?

A

joins all path segments that are used as arguments / can join 2 path names dynamically

80
Q

What does express.static() return?

A

returns the static files requested / function