Node.js Flashcards

(126 cards)

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
What is an absolute file path?
An absolute path always contains the root element and the complete directory list required to locate the file. Starts with a slash / (represents root)
26
What module does Node.js include for manipulating the file system?
Fs (file systems) module
27
What method is available in the Node.js fs module for writing data to a file?
fs.writeFile()
28
Are file operations using the fs module synchronous or asynchronous?
Asynchronous
29
What is a client?
Service requesters
30
What is a server?
Providers of a resource or service
31
Which HTTP method does a browser issue to a web server when you visit a URL?
GET
32
What is on the first line of an HTTP request message?
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
33
What is on the first line of an HTTP response message?
Protocol version (usually HTTP/1.1) Status code Status text
34
What are HTTP headers?
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
35
Is a body required for a valid HTTP message?
No GET, HEAD, DELETE, or OPTIONS usually do not have one
36
What is NPM? (Node Package Manager)
It is a software registry(a database) of public and private packages 3 components: Website Command line interface The registry
37
What is a package?
A package is a file or directory that is described by a package.json file.
38
How can you create a package.json with npm?
Run npm init --yes
39
What is a dependency and how do you add one to a package?
A dependency is another package that your package needs in order to work. Using npm install on the command line
40
What happens when you add a dependency to a package with npm?
The package gets downloaded from the registry and into node_modules & it also updates package.json to list the dependencies
41
How do you add express to your package dependencies?
npm install express
42
What Express application method starts the server and binds it to a network PORT?
The listen ( ) method
43
How do you mount a middleware with an Express application?
‘Use’ method of the ‘app’ object App.use
44
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
The request and response object
45
What does the express.json() middleware do and when would you need it?
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
46
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
header('Content-Type: application/json')
47
What is the significance of an HTTP request's method?
Allows for communication between client and servers Describes the intent of the client but is arbitrary (random), does not enforce anything
48
What is PostgreSQL and what are some alternative relational databases?
PostgreSQL is a powerful, free, open source Relational Database Management System (RDBMS) MySQL, SQL Server by Microsoft, and Oracle
49
What are some advantages of learning a relational database?
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
50
What is one way to see if PostgreSQL is running?
Open a second terminal and use top command to check if PostgreSQL is running
51
What is a database schema?
A collection of tables Defines how the data in a relational database should be organized
52
What is a table?
Data that is stored in relations A list of rows
53
What is a row?
A set of attributes | Also known as columns
54
What is SQL(Structured Query Language) and how is it different from languages like JavaScript?
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
How do you retrieve specific columns from a database table?
Using the ‘select’ statement with the name of the column in double quotes
56
How do you filter rows based on some specific criteria?
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
What are the benefits of formatting your SQL?
- Helps us make queries readable - Proper formatting allows us to easily find errors - Easier for other developers to understand
58
What are four comparison operators that can be used in a where clause?
= < > !=
59
How do you limit the number of rows returned in a result set?
By using the ‘limit’ clause with an integer
60
How do you retrieve all columns from a database table?
Using the ‘select’ clause with an asterisk (star)
61
How do you control the sort order of a result set?
By using the ‘order by’ clause with the column name in double quotes
62
How do you add a row to a SQL table?
With the ‘insert’ clause Insert into “table name” (“column names”....) Values (‘name of value’....)
63
What is a tuple?
A list of values
64
How do you add multiple rows to a SQL table at once?
By specifying more than one tuple of values
65
How do you get back the row being inserted into a table without a separate select statement?
With the ‘returning’ clause
66
How do you update rows in a database table?
Using the ‘update’ statement; ensure that a where clause is included
67
How do you delete rows from a database table?
With a ‘delete’ statement
68
How do you accidentally delete all rows from a table?
By using ‘delete’ from “table name” -If there is no specificity, everything from the table will get deleted and there is no undo
69
What is a foreign key?
A foreign key is a key used to link two tables together.
70
How do you join two SQL tables?
A SQL ‘join’ clause
71
How do you temporarily rename columns or tables in a SQL statement?
By aliasing column names with the ‘as’ keyword
72
What are some examples of aggregate functions?
``` max( ) avg( ) count( ) min ( ) sum ( ) every ( ) ```
73
What is the purpose of a ‘group by’ clause?
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
What are the three states a Promise can be in?
pending: initial state, neither fulfilled nor rejected. fulfilled: the operation was completed successfully. rejected: the operation failed.
75
How do you handle the fulfillment of a Promise?
By using the ‘then’ method and passing a callback
76
How do you handle the rejection of a Promise?
By using the ‘catch’ method of the promise object
77
What is Array.prototype.filter useful for?
Creates a new array with all elements that pass the test implemented by the provided function.
78
What is Array.prototype.map useful for?
Creates a new array while excluding some elements.
79
What is Array.prototype.reduce useful for?
It combines the elements of an array into a single value
80
What is "syntactic sugar"?
Syntax that is designed to make things easier to read or more concise
81
What is the typeof an ES6 class?
A function
82
Describe ES6 class syntax.
A function, class name, opening curly brace for class body and closing curly brace
83
What is "refactoring"?
Restructuring existing computer code without changing its external behavior Improves the design, structure, and/or implementation of the software while preserving its functionality
84
What is Webpack?
A tool that lets you compile JavaScript modules(files), also known as module bundler
85
How do you add a devDependency to a package?
npm install --save-dev
86
What is an NPM script?
NPM Scripts are a set of built-in and custom commands defined in the package.json file.
87
How do you execute Webpack with npm run?
npm run build
88
How are ES Modules different from CommonJS modules?
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
What kind of modules can Webpack support?
ECMAScript modules, CommonJS modules, AMD(Async Module Definition) modules (no one uses this one), assets (random files), and web assembly modules
90
What is React?
React is a JavaScript library for creating user interfaces.
91
What is a React element?
Plain objects that describe what the DOM should look like
92
How do you mount a React element to the DOM?
ReactDOM.render()
93
What is Babel?
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
What is a Plug-in?
A piece of software that adds new features or extends functionality on an existing application
95
What is a Webpack loader?
Loaders are transformations that are applied to the source code of a module.
96
How can you make Babel and Webpack work together?
By adding the babel plugins into webpack.config.js
97
What is JSX?
A syntax extension to JS
98
Why must the React object be imported when authoring JSX in a module?
JSX produces react elements therefore the React object must always be in scope for that production to happen
99
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
By connecting webpack and babel through babel loader and then adding the react jsx transform to babel
100
What is a React component?
React components allow us to split the UI into independent, reusable pieces They are conceptually like JS functions
101
How do you define a function component in React?
Function keyword, function name, parentheses, curly braces, return statement that returns a react element
102
How do you mount a component to the DOM?
By passing a react element as the first argument in ReactDOM.render
103
What are props in React?
Props are argument objects Contain all the props passed to the child component
104
How do you pass props to a component?
The prop name with an equal sign and the prop value
105
How do you write JavaScript expressions in JSX?
You write JS expressions in curly brackets
106
How do you create "class" component in React?
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
How do you access props in a class component?
By using the ‘this’ keyword?
108
What is the purpose of state in React?
State is a plain JavaScript object used by React that keeps tracks of value that change over time Controlled by the component
109
How do you pass an event handler to a React element?
By passing it as props to the child components
110
What Array method is commonly used to create a list of React elements?
The map ( ) function
111
What is the best value to use as a "key" prop when rendering lists?
Use a string that uniquely identifies a list item amongst its sibling IDs from our data
112
What are controlled components?
An input form element whose value is controlled by React
113
What two props must you pass to an input for it to be "controlled"?
- onChange and value | - Value is dictated by the state
114
What does express.static() return?
It returns the middleware function
115
What is the local __dirname variable in a Node.js module?
The _dirname is found in the absolute path wherever the node.js module exists
116
What does the join() method of Node's path module do?
Joins all specified path segments into one
117
What does fetch() return?
Returns a promise for a response object
118
What is the default request method used by fetch()?
GET
119
How do you specify the request method (GET, POST, etc.) when calling fetch?
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
When does React call a component's componentDidMount method?
After the component has been rendered
121
Name three React.Component lifecycle methods.
render ( ) constructor ( ) componentDidMount( )
122
How do you pass data to a child component?
Passing it through a prop
123
What must the return value of myFunction be if the following expression is possible? myFunction( )( );
myFunction will return the value of the second function return
124
``` What does this code do? const wrap = value => () => value; ```
The const variable Wrap is storing a function definition and that definition is also another function definition
125
In JavaScript, when is a function's scope determined; when it is called or when it is defined?
When it is defined; at definition time
126
What allows JavaScript functions to "remember" values from their surroundings?
Closures