Senior Side Week 1 Flashcards

1
Q

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

A

A code block is when their are lines of code that is grouped together. Typically code blocks are grouped by curly braces. Some example of code blocks are if statements, for loops, while, and do while loops

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

What does block scope mean?

A

Block scope means that any variable or function is only visible within that block of code and not outside of it

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

They have a block-level 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 variable cannot change while let variable can.

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 only applies to the variable reference (i.e., the memory address that the variable points to), not the value itself.

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 the variable needs to be mutable later on, use let. If the variable doesn’t change at all, then use const. If you don’t know if it is going to change just use const and change it back later.

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

The syntax is backticks (`)

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

What is “string interpolation”?

A

The syntax used is ${expression}. It is when you can insert the value of the expression within the string. Makes it easier to read the code.

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

What is destructuring, conceptually?

A

It makes it the code more concise and easier to readable. It allows us to assign elements in array or objects to variables so that it is easier to grab

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

let { firstName: fname, lastName: lname } = person;
//this is for renaming the variable

or

you can keep it like this
let { firstName, lastName } = person;

//this doesn’t rename it

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

Instead of brackets that are used in objects, we use square brackets with a variable name for each element for each index.

let [x, y, z] = array;

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

We can tell by which side the object and array is in the expression.

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

=>

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

The arrow function will automatically return the expression. If the expression is more than one statement then you you need curly braces and a return syntax

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

The “this” is determined by the scope in which the arrow function is defined and not where it is called

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

What is a CLI?

A

CLI stands for command-line interfaces. Uses the command-line interface to receive commands from a user in the form of 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

GUI stands for graphical user interface. It is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, instead of text-based UIs, typed command labels or text navigation. Typically used by consumers and not developers.

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

man

A

Definition: an interface to the system manuals

Description: man is the system’s manual pager. Each page argument given to man is normally the name of a program, utility or function. The manual page associated with each of these arguments is then found and displayed. A section, if provided, will direct man to look only in that section of the
manual. The default action is to search in all of the available sections following a pre-defined order (see DEFAULTS), and to show only the first page found, even if page exists in several sections.

Use Case: Used to find commands if you don’t know one

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

cat

A

Definition: concatenate files and print on the standard output

Description: Concatenate files to standard output

Use Case: to know what is in the file

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

ls

A

Definition: list directory contents

Description: List information about the FILEs

Use Case: To see what files are in the directory

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

pwd

A

Definition: print name of current/working directory

Description: Print the full filename of the current working directory

Use Case: to know the full path

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

echo

A

Definition: display a line of text

Description: the String(s) to standard output

Use Case: not really

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

touch

A

Definition: change file timestamps

Description: Update the access and modification times of each File to the current time.
A file argument that does not exist is created empty, unless -c or -h is supplied.
A file argument string of - is handled specially and causes touch to change the times of the file associated with standard output.

Use Case: makes a timestamp for a file and it can create a new file

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

mkdir

A

Definition: make directories

Description: Create the directory(ies) if they do not already exist.

Use Case: When you want to create a folder

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

mv

A

Definition: move (rename) files

Description: Rename source to dest, or move source(s) to directory

Use Case: to rename files

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

rm

A

Definition: remove files or directories

Description: removes each specified file. by default, it does not remove directories.

Use Case: To delete files

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

cp

A

Definition: copy files and directories

Description: Copy source to dest, or multiple source(s) to directory

Use Case: to copy files

28
Q

What are the three virtues of a great programmer?

A

laziness, hubris, impatience

29
Q

What are the 3 components of a fullstack Web architecture?

A

1) Presentation tier
2) Logic tier
3) Data tier

30
Q

What is Node.js?

A

Allows developers to run JavaScript code outside of a web browser. It is commonly used to build backends for Web applications, command-line programs, or any kind of automation that developers wish to perform.

31
Q

What can Node.js be used for?

A

It can be used for the server-side of applications and backends for Web applications

32
Q

What is a REPL?

A

It stands for read-eval-print loop. It is a programming language feature that allows developers to interactively execute code and see the results immediately. It can only take a single user input.

33
Q

When was Node.js created?

A

2009

34
Q

What backend languages have you heard of?

A

Python, Ruby, Java, PHP

35
Q

What is computer process?

A

A computer process refers to a series of task or operations that a computer or computer program performs to complete a specific task

36
Q

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

A

397

37
Q

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

A

Helps the developers create efficient, scalable, and optimized for performance

38
Q

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

A

The ‘process’ object is a ‘global’ that provides information about, and control over, the current Node.js process.

39
Q

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

A

Using the global variable ‘process’. This object provides the information about and control over the current Node.js process running the program.

40
Q

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

A

An array containing the command line arguments passed when the Node.js process was launched.

41
Q

How do you access the command line arguments in a Node.js program?

A

Use process.argv

42
Q

What is a JavaScript module?

A

A module is a single .js file. Every module is basically a file.

43
Q

What are the advantages of modular programming?

A

Reusability, maintainability, scalability, collaboration, organized, testing

44
Q

In JavaScript, how do you make a function in a module available to other modules?

A

Using export declaration.

You don’t need to use default. There is only one thing that can export by default.

If you don’t have default you need the curly braces.

45
Q

In JavaScript, how do you use a function from another module?

A

Using import declaration

46
Q

What is the JavaScript Event Loop?

A

The event loop’s job is to look at the stack and the task.queue. If the stack is empty it takes the first thing on the queue and pushes it on to the stack. It has to wait till the stack is cleared for the event loop to kick in

47
Q

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

A

Blocking: Synchronous. Slow. Waits till a code finishes running before it goes to the next. This can halt and processes in the browser till it finishes a whichever line of code that comes first,.

Non-blocking: Asynchronous. Fast.

48
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

49
Q

How do you handle the fulfillment of a Promise?

A

using ‘.then’

50
Q

How do you handle the rejection of a Promise?

A

using ‘.catch’

51
Q

What does ‘Array.filter’ do?

A

It filters down the array based on if the function given passes the requirements. It doesn’t modify the array. so make sure to assign it to a variable

52
Q

What should the callback function return?

A

It should return a boolean value.
It should return a portion of the given array, filtered down to just the elements from the given array that passes the test implemented by the provided function.

53
Q

What is Array.filter useful for?

A

It’s useful for finding the elements that you only want to search for.

54
Q

What does ‘Array.map’ do?

A

Creates a new array with the results of calling a provided function on every element in the calling array.

55
Q

What should the callback function return?

A

It returns a new array with each element being the result of the callback function.

56
Q

What is ‘Array.map’ useful for?

A

It is useful if you need to manipulate all the elements in the array

57
Q

What does ‘Array.reduce’ do?

A

Reduce an array to a single value by iterating over its elements and applying a function that accumulates the results.

58
Q

What action should the callback function perform?

A

The callback function that is passed as the first argument to Array.reduce() should perform the action that you want to apply to each element of the array, and accumulate the result into the accumulator.

It accumulates each element in order.

59
Q

What should the callback function return?

A

The value that results from running the ‘reducer’ callback function to completion over the entire array. Typically, the accumulated value.

60
Q

What is Array.reduce useful for?

A

To sum up the entire array, finding the max and min values of an array, flatten nested arrays, grouping objects by specific properties

61
Q

What is a directory?

A

A container that stores files and other directories. Known as a folder.

62
Q

What is a relative file path?

A

A relative file is a file path that is relative to the current working directory or location of the file being accessed.

63
Q

What is an absolute file path?

A

A file path that specifies the complete path to a file or directory on a file system. Absolute always starts at the root.

64
Q

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

A

The ‘fs’ (file system) module for manipulating the file system.
The “fs” module provides methods for working with files, directories, and file system operations like reading and writing files, creating and deleting directories, renaming and moving files, and other file-related tasks.

65
Q

What method is available in the node:fs module for reading data from a file?

A

fs.readFile

66
Q

What method is available in the ‘node:fs’ module for writing data to a file?

A

writeFile

67
Q

Are file operations using the ‘fs’ module synchronous or asynchronous?

A

Asynchronous