ES6 Flashcards

1
Q

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

A

the code inside of curly braces {}

function code block, conditionals, 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 variables are only attached to what’s inside of the block, they do not attach to the global object (the window object)

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

Const and Let are block-scoped - cannot be accessed outside particular block

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

let can have its value reassigned, const cannot have its value reassigned.

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

.push is not reassigning or redeclaring the variable, it is simply adding to the array

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

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

A

Use const by default unless the variable’s value will need to change

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

use backticks `` and use ${variable}

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

What is “string interpolation”?

A

the ability to substitute part of a string for the values of variables or expression

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

What is destructuring, conceptually?

A

Taking data out of either an object or an array and assigning it to individual 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

Const {propertyName: variable1, propertyName2: variable2; etc…} = objectName

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

Const [variablename1, variablename2, variablename3, etc] = arrayName

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

Curly Braces vs square brackets

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

Parameters => expression

Const fnName = (Parameters) => {codeblock with return}

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

You can only put one expression to the right of the arrow, has an implicit return, result of that expression is returned

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

Has lexical scoping to this context

Value of this is defined at definition

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 - connects user to a computer program or OS
Text based interface that runs programs, manage computer files and interacts with computer

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

What is a GUI?

A

Graphical User Interface - computer programs that provide a visual means for users to interact with an underlying application or system.

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

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

A

Man - manual, view the manual of the certain command
Cat - outputs content of the file or concat files together
Ls - lists directory contents
Pwd - display path of current working file(where am i?)
Echo -displays line of text within CLI(console.log for terminal)
Touch - update file access , modify time and create file if one does not exist
Mkdir - make a directory
Mv - move(rename) files (files name is its location)
Rm - remove(delete) directory -f is force delete
Cp - copy file or directory, can override an existing file

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

What are the three virtues of a great programmers?

A

Laziness, Impatience, Hubris

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

What is Node.JS?

A

Open source, cross platform runtime environment that allows developers to create all kinds of server-side tools and applications in javascript. Allow users to run javascript outside of the browser

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

What can Node.js be used for?

A

Node. js is primarily used for non-blocking, event-driven servers, due to its single-threaded nature. It’s used for traditional web sites and back-end API services, but was designed with real-time, push-based architectures in mind.

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

What is a REPL?

A

Read Eval Print Loop - takes user inputs, executes them and returns to user

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

What back end languages have you heard of?

A

python , node, php, javascript, ruby, java, GoLang, C#

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is the process object in a Node.js program?
It's a global that provides information about, and control over, the current Node.js process.
26
How do you access the process object in a Node.js program?
As a global, it is always available to Node.js applications without using require(). It can also be explicitly accessed using require()
27
What is the data type of process.argv in Node.js?
Object | Array of strings
28
What is a JavaScript module?
Single .js file , each provide its own chunk of functionality
29
What values are passed into a Node.js module's local scope?
exports, require, module, __filename, __dirname
30
Give two examples of truly global variables in a Node.js program.
Process and global
31
What is the purpose of module.exports in a Node.js module?
Be able to export code into another module
32
How do you import functionality into a Node.js module from another Node.js module?
require() and pass in the relative path of the file as a string argument
33
What is the JavaScript Event Loop?
responsible for executing the code, collecting and processing events, and executing queued sub-tasks
34
What is the difference between "blocking" and "non-blocking" with respect to how code is executed?
Fast vs slow code, prevents us from continuing the code and we can only proceed once the code block has been executed
35
What is a directory?
File system structure which contains references to other files and possibly other directories
36
What is a relative file path?
Location of file using current directory as a reference, uses current or parent directory as reference to specify path relative to it.
37
What is an absolute file path?
Specific location in a file system not related to current directory, specify location from root directory (/)
38
What module does Node.js include for manipulating the file system?
Fs module
39
What method is available in the Node.js fs module for writing data to a file?
fs.writeFile()
40
Are file operations using the fs module synchronous or asynchronous?
yes
41
What is a client?
Someone who requests a service, browser and http pie
42
What is a server?
Program or device that receives requests from client and sends back data
43
Which HTTP method does a browser issue to a web server when you visit a URL?
`GET
44
What is on the first line of an HTTP request message?
HTTP method; a verb or noun that describes action being performed The target request: either a URL or absolute path of the protocol, port, and domain are usually characterized by the request context. HTTP version that is being used
45
What is on the first line of an HTTP response message?
Protocol version: http version Status code: example 404 Status text: text description of the status code to help humans understand http message
46
What are HTTP headers?
Meta deta from the http request
47
Is a body required for a valid HTTP message?
No
48
What is NPM?
``` Node package manager, open source , world’s largest software registry, allows developers to share and borrow packages. Consists of three things: The website The CLI The registry ```
49
What is a package?
file or directory that is described by a package.json file. (must have this file). all the files you need for a module
50
How can you create a package.json with npm?
npm init -yes
51
What is a dependency and how do you add one to a package?
packages required by your application add by npm install (package name)
52
What happens when you add a dependency to a package with npm?
It adds library to json Object
53
How do you add express to your package dependencies?
create new project, npm init -yes npm install express verify it in the JSON object
54
What Express application method starts the server and binds it to a network port?
LISTEN
55
How do you mount a middleware with an express application?
USE
56
Which objects does an Express application pass to your middleware to manage?
req and res objects (Request and Response)
57
What is the appropriate CONTENT-TYPE header for HTTP messages to contain JSON in their bodies?
application/JSON
58
What does the express.json() middleware do and when would you need it?
parses incoming request with json payload and is based on body-parser. Where is the actual data? BODY!!!! (header/blank line/body) ---> it looks for the json data in the body. Will send empty object if the JSON wasn't sent correctly.
59
What is the significance of an HTTP request’s method?
HTTP defines a set of request methods to indicate the desired action to be performed for a given resource.
60
What are the three states a promise can be in ?
Pending: initial state Fulfilled: meaning that the operation was successful Rejected: operation failed
61
How do you handle the fulfillment of a Promise?
THEN method
62
How do you handle the rejection of a Promise?
CATCH method
63
What is Array.Prototype.Filter useful for?
Sort elements out of array with certain conditions
64
What is Array.Prototype.Map useful for?
Creates new array populated with the results of calling a provided function on every element in the calling array.
65
What is Array.prototype.Reduce useful for?
The reduce() method executes a user-supplied "reducer" callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.
66
What is "syntactic sugar"?
Changing the syntax to make it easier to read or express
67
What is the typeOf an ES6 class?
FUNCTION
68
Describe the ES6 class syntax
``` class keyword nameOfClass{ constructor keyword(parameters){ } } ```
69
What is "refactoring"?
The process of restructuring existing computer code without changing or adding to its external behavior or functionality.
70
What is Webpack?
This is why webpack exists. 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. Node js to bundle everything
71
How do you add a devDependency to a package?
--save-dev
72
What is an NPM Script?
Set of built-in and custom functions defined within the package.json file that all you to do certain things within your application
73
How do you execute webpack with npm run?
npm run
74
How are ES Modules different from CommonJS modules?
Their syntax is more compact Their structure cam be statically analyzed Their support for cyclic dependencies is better than CommonJSs Specific keywords in ES , common JS calls functions
75
What kind of modules can Webpack support?
ECMAScript Modules, CommonJS, AMD Modules
76
What does fetch() return?
Returns a promise that resolves with a RESPONSE object Doesnt contain actual JSON response body, but instead a representation of the entire http response. Use the json() method which returns a second promise that resolves with the result of parsing the response body text as JSON
77
What is the default request method used by fetch()?
GET method
78
How do you specify the request method (GET, POST, etc.) when calling fetch?
Create a new request and in the second argument create an object literal with a method property with the value being whatever method you would like to use
79
What does express.static() return?
Returns ServeStatic function | Create a new middleware function to serve files from within a given root directory
80
What is the local __dirname variable in a Node.js module?
Absolute path of the directory name
81
What does the join() method of Node's path module do?
Joins all the paths together into a single path string by puting slash between each
82
What must the return value of myFunction be if the following expression is possible?
myFunction()(); | Must return another function
83
``` What does this code do? const wrap = value => () => value; ```
function that takes single param, and then there is a function that takes no params, and it returns the outter params.
84
In JavaScript, when is a function's scope determined; when it is called or when it is defined?
At definition
85
What allows JavaScript functions to "remember" values from their surroundings?
closures
86
What does the acronym LIFO mean?
Last In First Out
87
What methods are available on a Stack data structure?
push(value), pop()
88
What must you do to access the value at an arbitrary point in a stack (not just the "top")?
peek()
89
What does the acronym FIFO mean?
First In First Out
90
What methods are available on a Queue data structure?