Node and The Senior Side Flashcards

1
Q

What is a code block? What are some examples of a code block?

A

In JavaScript, blocks are denoted by curly braces {} , for example, the if else, for, do while, while, try catch and etc.

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

What does block scope mean?

A

The context in which values and expressions are “visible” or can be referenced. If a variable or other expression is not “in the current scope,” then it is unavailable for use.

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

What is the scope of a variable declared with const or let?

A

let and const are blocked-scope,

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

What is the difference between let and const?

A

const is immutable, use it if you don’t plan on reassigning that variable

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

Why is it possible to .push() a new value into a const variable that points to an Array?

A

The const keyword ensures that the variable it creates is read-only. However, it doesn’t mean that the actual value to which the const variable reference is immutable. However, you cannot reassign a different value to the person constant like this. you’re not changing memory address.

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

How should you decide on which type of declaration to use?

A

If you plan on re-using it or not.

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

What is the syntax for writing a template literal?

A

Using a backtick character, which will produce a new string

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

What is “string interpolation”?

A

String formatting: the ability to substitute part of the string for the values of variables or expressions.

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

What is destructuring, conceptually?

A

The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.

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

What is the syntax for Object destructuring?

A

declare a variable, have open curly braces, if necessary, give a property name, but you can be concise and reference the property.

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

What is the syntax for Array destructuring?

A

a variable with open brackets, and more variables within the brackets being = array variable name. order matters

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

How can you tell the difference between destructuring and creating Object/Array literals?

A

The Order of assignment

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

What is the syntax for defining an arrow function?

A

A variable with a name with an assignment operator with an arrow function with a parameter and then curly braces

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

When an arrow function’s body is left without curly braces, what changes in its functionality?

A

it expects one expression and automatically returns that expression. implicit means implied.

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

How is the value of this determined within an arrow function?

A

Arrow functions have a lexical this and its value within the arrow function is determined by the surrounding scope.

Where the function is defined… where as previous it was call time.

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

What is a CLI?

A

Command-line-interface, processes commands via lines of text

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

What is a GUI?

A

Graphic user interface, aimed at consumers of technology

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

Use Case for Man

A

Man displays the on-line manual pages, you can specify sections with it.

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

Use case for Cat

A

reads files sequentially, writing them to the standard output. in the exercise we could read a text file

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

Use case for ls

A

list directory contents

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

use case for pwd

A

writes absolute path name

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

use case for echo

A

write arguments to the standard output. we wrote a string, console log for console

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

use case for touch

A

Change file access and modify items, create file

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

use case for mkdir

A

make directories

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

use case for mv

A

move files or rename them

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

use case for rmman

A

remove directory files or directory with -r

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

Use case for cp

A

copy files or directories with -r

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

What are the three virtues of a great programmer?

A

laziness, impatience, and hubris

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

What is node.js

A

Allows to run javaScript outside the browser, commonly used to build back ends for web browsers, 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
30
Q

What can Node.js be used for?

A

Node.js is designed to build scalable network applications, web application s that seamlessly and efficiently accommodate growth, and be designed with scalability in mind. Node.js can be used for everything, don’t

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

What is a REPL?

A

Stands for, Read–eval–print loop, and it takes single user inputs, executes them, and returns the result to the user

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

When was Node.js created?

A

2009,

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

What back end languages have you heard of?

A

python, java, sql, javascript, ruby, Go, C++, C#, Rust, F#

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

What is a computer process?

A

is the instance of a computer program that is being executed by one or many threads. It contains the program code and its activity.

A compute instance can be software or hardware which can run code, for example a CPU, GPU or a virtual machine

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

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

A

365

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

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

A

Because if it’s extremely demanding, nobody will use your stuff. Plus the better optimized it is, the more people can use it.

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

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

A

global 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
38
Q

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

A

you can explicity get it through require

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

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

A

array

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

What is a JavaScript module?

A

a file containing related code

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

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

A

exports, module, the five

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

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

A

console, process, Object, undefined

43
Q

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

A

So it can send out the data that’s being return’d from the function

44
Q

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

A

call the local require() function

45
Q

What is the JavaScript Event Loop?

A

It looks at the stack and the task queue, if the stack is empty, it takes the first thing in the queue and pushes it into the stack, which runs it

allows us to async

46
Q

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

A

blocking: code that is slow

Blocking methods execute synchronously and non-blocking methods execute asynchronously.

47
Q

What is a directory?

A

a file system structure that contains references to other computer files

48
Q

What is a relative file path?

A

hierarchical path that locates a file or directory on a file system starting from the current directory

49
Q

What is an absolute file path?

A

always contains the root element and the complete directory list required to locate the file. starts from the root/ or windows d

50
Q

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

A

fs module

51
Q

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

A

writeFile method

52
Q

Are file operations using the fs module synchronous or asynchronous?

A

asynch

53
Q

What is NPM?

A

it’s a software registry, for open source devs to share or borrow packages.

54
Q

What is a package?

A

A package is a file or directory that is described by a package.json file. A package must contain a package.json file in order to be published to the npm registry.

55
Q

How can you create a package.json with npm?

A

Set up an account on npm, then use npm publish. Make sure your package.json is configured properly. npm innit – yes

56
Q

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

A

Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.

To specify the packages your project depends on, you must list them as “dependencies” or “devDependencies” in your package’s package.json file.

57
Q

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

A

your package.json gets updated with the required semantics, to specify the packages your project depends on. Since it’s a record. In node-modules, it has all the required files it depends on.

58
Q

How do you add express to your package dependencies?

A

npm install express

59
Q

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

A

the listen method

60
Q

How do you mount a middleware with an Express application?

A

Through the use method, include the two parameters res, or req

61
Q

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

A

A request object, which represents the incoming request. The second one is the response object, which represents the outgoing object. In general it’s text information that doesn’t pertain to any programming language. Express takes that data, parses it, and turns it into an object

62
Q

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

A

application/json

63
Q

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

A

to deal with the (incoming) data (object) in the body of the request.

64
Q

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

A

It’s ultimately how all clients and servers interact, regardless of platform, to simply boil it down, it’s how the web works.

65
Q

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

A

It’s ultimately how all clients and servers interact, regardless of platform, to simply boil it down, it’s how the web works.

66
Q

What is PostgreSQL and what are some alternative relational databases?

A

a open source Relational Database Management System, it features ACID properties, automatically updatable views, materialized views, triggers, foreign keys, and stored procedures.

Similar databases are microsoft server sql, mysql, and oracle database
postgress can manage multiple database
All based on the relational model of data,

67
Q

What are some advantages of learning a relational database?

A

For a first time learner, it’s a lot easier to know what is going on. Relational databases are arguably the most widely used kind of database.

As for a database itself, it’s a lot easier to scale, provides a set of tools (getting, updating), also a lot of them offer security features.

68
Q

What is one way to see if PostgreSQL is running?

A

top or sudo service postgresql status

69
Q

What is a database schema?

A

a collection of tables, schema defines how the data in a relational database should be organized. In the exercise pagalin was the schema.

70
Q

What is a table?

A

Relational databases store data in relations, a list of rows each having the same set of attributes, in our case the actors, countries were all tables. “firstName”, “lastName”, and “dateOfBirth” attributes. also called columns

71
Q

What is a row?

A

Describes the value of that attribute for that particular id, all rows have the same attributes.

72
Q

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

A

SQL is a declarative programming language.programmers describe the results they want and the programming environment comes up with its own plan for getting those results.

73
Q

How do you retrieve specific columns from a database table?

A

Through using SELECT statement

74
Q

How do you filter rows based on some specific criteria?

A

using WHERE statement

75
Q

What are the benefits of formatting your SQL?

A

makes it easier to read, helps a lot for troubleshooting

76
Q

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

A

=, and != less than operator and greater than operator

77
Q

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

A

using the limit statement

78
Q

How do you retrieve all columns from a database table?

A

asterisk

79
Q

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

A

using order by

80
Q

How do you add a row to a SQL table?

A

insert statement

81
Q

What is a tuple?

A

a list of values

82
Q

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

A

specifying more than one tuple of values, separated by commas.

83
Q

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

A

returning statement

84
Q

How do you update rows in a database table?

A

use the update statement (classify table)

then set whatever row

85
Q

Why is it important to include a where clause in your update statements?

A

so everything doesnt get updated

86
Q

How do you delete rows from a database table?

A

delete statement, classify where with

87
Q

How do you accidentally delete all rows from a table?

A

use the delete statement by itself

88
Q

What is a foreign key?

A

A foreign key is a set of attributes in a table that refers to the primary key of another table. The foreign key links these two tables.

89
Q

How do you join two SQL tables?

A

with the join statement, find the table where you want to join have the using keyword and select the attribute that’s in both

90
Q

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

A

you can alias them by selecting the table name, have a dot, find its name under that table then use as word to assign it a new name.

91
Q

What are some examples of aggregate functions?

A

AVG() – returns the average of a set.
COUNT() – returns the number of items in a set.
MAX() – returns the maximum value in a set.
MIN() – returns the minimum value in a set.
SUM() – returns the sum of all or distinct values in a set.

92
Q

What is the purpose of a group by clause?

A

used to arrange identical data into groups with the help of some functions

93
Q

What are the three states a Promise can be in?

A

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

94
Q

How do you handle the fulfillment of a Promise?

A

with the then method

95
Q

How do you handle the rejection of a Promise?

A

with the catch method

96
Q

What is Webpack?

A

Webpack is an open-source JavaScript module bundler.

webpack allows you to specify parts of a website, specifically “static assets” into smaller bundles so that the site loads more efficiently.

Now, in order to load the page, the browser has to make an individual request and response for each of those CSS files and JS files to retrieve, which wastes time.

Webpack takes the files specified, combines them into one file, and then tries to shrink that one file down as much as it can by replacing variable names like “this_is_a_super_long_variable_name” to “a36”.

97
Q

How do you add a devDependency to a package?

A

You can add it manually or use npm install package –save-dev

98
Q

What is an NPM script?

A

a convenient way to bundle common shell commands for your project.

scripts are located in the package.json

99
Q

How do you execute Webpack with npm run?

A

do npm run build “build was the property of the script”

100
Q

How are ES Modules different from CommonJS modules?

A

outside of their different import and export syntax, ES Modules

In CommonJS, require() is synchronous; it doesn’t return a promise or call a callback. require() reads from the disk (or perhaps even from the network), and then immediately runs the script, they are dynamic. commonJS is from community

In ESM, the module loader runs in asynchronous phases. In the first phase, it parses the script to detect calls to import and export without running the imported script. they are static. it’s built in

101
Q

What kind of modules can Webpack support?

A

ECMAScript modules. CommonJS modules. AMD (Asynchronous module definition) modules. WebAssembly

102
Q

What does express.static() return?

A

middleware is software that sits in between two other pieces of software and performs some defined function.

It allows the user to load the static files that are in the public directory:

103
Q

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

A

tells you the absolute path of the directory containing the currently executing file

104
Q

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

A

It returns a string with the complete normalized path containing all the segments.