Node.js Flashcards

1
Q

What is a CLI?

A

Command-line interface

Allows users to interact with a computer program by typing in text/commands

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

What is a GUI?

A

Graphical user interface

Allows user to interact with electronic devices through graphical icons and audio indicator

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

Give at least one use case for each of the commands listed in this exercise.

  • man
  • cat
  • ls
  • pwd
  • echo
  • touch
  • mkdir
  • mv
  • rm
  • cp
A

man: man is an interface to the on-line reference manuals
cat: concatenate files and print on the standard output
ls: list directory contents of current directory
pwd: print name of current/working directory
echo: display a line of text
touch: change file to time stamps
mkdir: makes directories
mv: move (rename) files
rm: remove files or directories
cp: copy files & directories

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

What are the three virtues of a great programmer?

A
  1. laziness
  2. impatience
  3. hubris
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Node.js?

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
6
Q

What can Node.js be used for?

A

Used to build back ends for Web applications, command-line programs, or any kind of automation

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

What is a REPL?

A

Read-eval-print loop

A simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user

It is a loop because it waits for the input before executing again

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

When was Node.js created?

A

May 27, 2009

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

What back end languages have you heard of?

A

Python, Ruby, Java, Node.js (JavaScript)

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

What is a computer process?

A

Instance of a running program

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

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

A

Around 600

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

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

A

It is a web developers job to make multiple processes work together to form one application

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

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

A

The process object is 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
14
Q

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

A

Can be accessed anywhere since it is global

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
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
16
Q

What is a JavaScript module?

A

A single .js file

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

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

A
  1. exports
  2. require
  3. module
  4. __filename
  5. __dirname
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

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

A

Global

Process

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

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

A

It allows us to separate a large code into smaller modules that can be exported when called/needed

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

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

A

By using require( )

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

What is the JavaScript Event Loop?

A

The event loop is a process that waits for the Call Stack to be clear before pushing callbacks from the Task Queue to the Call Stack.

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

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

A

Blocking - execute synchronously (does one task at a time)

Non-blocking - execute asynchronously (can do another task before previous one is finished)

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

What is a directory?

A

Special folder that contains other files

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

What is a relative file path?

A

Locates a file or folder on a file system starting from the current directory

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

What is an absolute file path?

A

An absolute path always contains the root element and the complete directory list required to locate the file.

Starts with a slash / (represents root)

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

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

A

Fs (file systems) module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
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
28
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
29
Q

What is a client?

A

Service requesters

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

What is a server?

A

Providers of a resource or service

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

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

A

GET

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

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

A

An HTTP method- verb like GET, PUT, POST

The Request target - usually a url

The HTTP version - for web development, will always be HTTP/1.1

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

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

A

Protocol version (usually HTTP/1.1)

Status code

Status text

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

What are HTTP headers?

A

HTTP headers are used to pass additional information between the clients and the server through the request and response header.

Metadata about the request or response

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

Is a body required for a valid HTTP message?

A

No

GET, HEAD, DELETE, or OPTIONS usually do not have one

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

What is NPM? (Node Package Manager)

A

It is a software registry(a database) of public and private packages

3 components:
Website
Command line interface
The registry

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

What is a package?

A

A package is a file or directory that is described by a package.json file.

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

How can you create a package.json with npm?

A

Run npm init –yes

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

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

A

A dependency is another package that your package needs in order to work.

Using npm install on the command line

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

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

A

The package gets downloaded from the registry and into node_modules & it also updates package.json to list the dependencies

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

How do you add express to your package dependencies?

A

npm install express

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

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

A

The listen ( ) method

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

How do you mount a middleware with an Express application?

A

‘Use’ method of the ‘app’ object

App.use

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

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

A

The request and response object

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

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

A

If the client is sending json in the body of the request, the middleware is responsible for parsing that request value into an object and stick it onto req.body

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

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

A

header(‘Content-Type: application/json’)

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

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

A

Allows for communication between client and servers

Describes the intent of the client but is arbitrary (random), does not enforce anything

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

What is PostgreSQL and what are some alternative relational databases?

A

PostgreSQL is a powerful, free, open source Relational Database Management System (RDBMS)

MySQL, SQL Server by Microsoft, and Oracle

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

What are some advantages of learning a relational database?

A

Supports data integrity

Can store and modify data in way that makes data corruption unlikely

It is the mostly used kind of database so understanding how it works as a web developer is important

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

What is one way to see if PostgreSQL is running?

A

Open a second terminal and use top command to check if PostgreSQL is running

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

What is a database schema?

A

A collection of tables

Defines how the data in a relational database should be organized

52
Q

What is a table?

A

Data that is stored in relations

A list of rows

53
Q

What is a row?

A

A set of attributes

Also known as columns

54
Q

What is SQL(Structured Query Language) and how is it different from languages like JavaScript?

A

Primary way of interacting with relational databases.

-It is a powerful way of retrieving, creating, and manipulating data in a relational database.

It is a declarative language
-Like HTML and CSS

55
Q

How do you retrieve specific columns from a database table?

A

Using the ‘select’ statement with the name of the column in double quotes

56
Q

How do you filter rows based on some specific criteria?

A

By using ‘where’ clause, the name of the column where the row exist, a comparison operator, and the text value in single quotes

where brand = ‘apple’

57
Q

What are the benefits of formatting your SQL?

A
  • Helps us make queries readable
  • Proper formatting allows us to easily find errors
  • Easier for other developers to understand
58
Q

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

A

=

<

>

!=

59
Q

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

A

By using the ‘limit’ clause with an integer

60
Q

How do you retrieve all columns from a database table?

A

Using the ‘select’ clause with an asterisk (star)

61
Q

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

A

By using the ‘order by’ clause with the column name in double quotes

62
Q

How do you add a row to a SQL table?

A

With the ‘insert’ clause

Insert into “table name” (“column names”….)
Values (‘name of value’….)

63
Q

What is a tuple?

A

A list of values

64
Q

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

A

By specifying more than one tuple of values

65
Q

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

A

With the ‘returning’ clause

66
Q

How do you update rows in a database table?

A

Using the ‘update’ statement; ensure that a where clause is included

67
Q

How do you delete rows from a database table?

A

With a ‘delete’ statement

68
Q

How do you accidentally delete all rows from a table?

A

By using ‘delete’ from “table name”

-If there is no specificity, everything from the table will get deleted and there is no undo

69
Q

What is a foreign key?

A

A foreign key is a key used to link two tables together.

70
Q

How do you join two SQL tables?

A

A SQL ‘join’ clause

71
Q

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

A

By aliasing column names with the ‘as’ keyword

72
Q

What are some examples of aggregate functions?

A
max( )
avg( )
count( )
min ( )
sum ( )
every ( )
73
Q

What is the purpose of a ‘group by’ clause?

A

Used to group rows that have the discernible(noticeable, same) values.

Tim’s definition:
Is to cluster/segregate/subdivide rows in a result set into groups and perform an aggregate on each group

74
Q

What are the three states a Promise can be in?

A

pending: initial state, neither fulfilled nor rejected.
fulfilled: the operation was completed successfully.
rejected: the operation failed.

75
Q

How do you handle the fulfillment of a Promise?

A

By using the ‘then’ method and passing a callback

76
Q

How do you handle the rejection of a Promise?

A

By using the ‘catch’ method of the promise object

77
Q

What is Array.prototype.filter useful for?

A

Creates a new array with all elements that pass the test implemented by the provided function.

78
Q

What is Array.prototype.map useful for?

A

Creates a new array while excluding some elements.

79
Q

What is Array.prototype.reduce useful for?

A

It combines the elements of an array into a single value

80
Q

What is “syntactic sugar”?

A

Syntax that is designed to make things easier to read or more concise

81
Q

What is the typeof an ES6 class?

A

A function

82
Q

Describe ES6 class syntax.

A

A function, class name, opening curly brace for class body and closing curly brace

83
Q

What is “refactoring”?

A

Restructuring existing computer code without changing its external behavior

Improves the design, structure, and/or implementation of the software while preserving its functionality

84
Q

What is Webpack?

A

A tool that lets you compile JavaScript modules(files), also known as module bundler

85
Q

How do you add a devDependency to a package?

A

npm install –save-dev

86
Q

What is an NPM script?

A

NPM Scripts are a set of built-in and custom commands defined in the package.json file.

87
Q

How do you execute Webpack with npm run?

A

npm run build

88
Q

How are ES Modules different from CommonJS modules?

A

CommonJs

  • Is not supported by browser & not part of JS language
  • Uses require( ) and module.exports

ES Modules

  • Officially a part of JS language and supported by browser
  • Uses import and export
89
Q

What kind of modules can Webpack support?

A

ECMAScript modules, CommonJS modules, AMD(Async Module Definition) modules (no one uses this one), assets (random files), and web assembly modules

90
Q

What is React?

A

React is a JavaScript library for creating user interfaces.

91
Q

What is a React element?

A

Plain objects that describe what the DOM should look like

92
Q

How do you mount a React element to the DOM?

A

ReactDOM.render()

93
Q

What is Babel?

A

A transcompiler (software that translate code, think of a language translator) that converts ES 2015+ code into a backwards compatible version of JavaScript that can be run by older JavaScript engines

94
Q

What is a Plug-in?

A

A piece of software that adds new features or extends functionality on an existing application

95
Q

What is a Webpack loader?

A

Loaders are transformations that are applied to the source code of a module.

96
Q

How can you make Babel and Webpack work together?

A

By adding the babel plugins into webpack.config.js

97
Q

What is JSX?

A

A syntax extension to JS

98
Q

Why must the React object be imported when authoring JSX in a module?

A

JSX produces react elements therefore the React object must always be in scope for that production to happen

99
Q

How can you make Webpack and Babel work together to convert JSX into valid JavaScript?

A

By connecting webpack and babel through babel loader and then adding the react jsx transform to babel

100
Q

What is a React component?

A

React components allow us to split the UI into independent, reusable pieces

They are conceptually like JS functions

101
Q

How do you define a function component in React?

A

Function keyword, function name, parentheses, curly braces, return statement that returns a react element

102
Q

How do you mount a component to the DOM?

A

By passing a react element as the first argument in ReactDOM.render

103
Q

What are props in React?

A

Props are argument objects

Contain all the props passed to the child component

104
Q

How do you pass props to a component?

A

The prop name with an equal sign and the prop value

105
Q

How do you write JavaScript expressions in JSX?

A

You write JS expressions in curly brackets

106
Q

How do you create “class” component in React?

A

With the class keyword, the class name, extend keyword, React.Component, opening & closing curly brace, a render method, and the return of a react element

107
Q

How do you access props in a class component?

A

By using the ‘this’ keyword?

108
Q

What is the purpose of state in React?

A

State is a plain JavaScript object used by React that keeps tracks of value that change over time

Controlled by the component

109
Q

How do you pass an event handler to a React element?

A

By passing it as props to the child components

110
Q

What Array method is commonly used to create a list of React elements?

A

The map ( ) function

111
Q

What is the best value to use as a “key” prop when rendering lists?

A

Use a string that uniquely identifies a list item amongst its sibling

IDs from our data

112
Q

What are controlled components?

A

An input form element whose value is controlled by React

113
Q

What two props must you pass to an input for it to be “controlled”?

A
  • onChange and value

- Value is dictated by the state

114
Q

What does express.static() return?

A

It returns the middleware function

115
Q

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

A

The _dirname is found in the absolute path wherever the node.js module exists

116
Q

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

A

Joins all specified path segments into one

117
Q

What does fetch() return?

A

Returns a promise for a response object

118
Q

What is the default request method used by fetch()?

A

GET

119
Q

How do you specify the request method (GET, POST, etc.) when calling fetch?

A

The second argument is going to be an object literal with the property Method then the request method.

Example:
fetch(‘https://pokeapi.co/api/v2/pokemon/4’, {
method: ‘GET’
})

120
Q

When does React call a component’s componentDidMount method?

A

After the component has been rendered

121
Q

Name three React.Component lifecycle methods.

A

render ( )
constructor ( )
componentDidMount( )

122
Q

How do you pass data to a child component?

A

Passing it through a prop

123
Q

What must the return value of myFunction be if the following expression is possible?

myFunction( )( );

A

myFunction will return the value of the second function return

124
Q
What does this code do?
const wrap = value => () => value;
A

The const variable Wrap is storing a function definition and that definition is also another function definition

125
Q

In JavaScript, when is a function’s scope determined; when it is called or when it is defined?

A

When it is defined; at definition time

126
Q

What allows JavaScript functions to “remember” values from their surroundings?

A

Closures