AJAX/ES6 Flashcards

1
Q

What is a client?

A

A computer or program that request services from a server

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

What is a server?

A

A computer or program (or process) that runs the service to be shared with clients

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

What three things are on the start-line of an HTTPrequestmessage?

A
  1. An HTTP method (GET, PUT, POST)
  2. The request target (usually a URL, everything after the domain, aka after the http://example.com/, Aks the query string)
  3. The HTTP version, the expected version to use for the response
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What three things are on the start-line of an HTTPresponsemessage?

A
  1. The Protocol version (usually HTTP.1.1)
  2. The status code, indicating success or failure of the request (200 OK, 200s are successful, 404, 302 common)
  3. A status text, brief description of the status code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are HTTP headers?

A

Additional information shared between client and servers in a response (like location or the server providing it) or request (like information of the client requesting the resource)

For example,a request message can use headers to indicate it’s preferred media formats, while a response can use header to indicate the media format of the returned body.

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

Where would you go if you wanted to learn more about a specific HTTP Header?

A

MDN

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

Is a body required for a valid HTTP request or response message?

A

No, it is not required. It would include data associated with the request (like content of an HTML form)

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

What is AJAX?

A

A technique used for loading data into a page without having to refresh the entire page

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

What does the AJAX acronym stand for?

A

Asynchronous JavaScript And XML(Extensible markup language)

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

Which object is built into the browser for making HTTP requests in JavaScript?

A

XMLHttpRequest object (xhr)

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

What event is fired byXMLHttpRequestobjects when they are finished loading the data from the server?

A

Load event

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

Bonus Question: AnXMLHttpRequestobject has anaddEventListener()method just like DOM elements. How is it possible that they both share this functionality?

A

They have a shared prototype object

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

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

A

Any code within curly braces
If else statements, for statements, do while statements

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

What does block scope mean?

A

It will not be accessible from outside the block that its in

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

What is the scope of a variable declared withconstorlet?

A

Block-scope

17
Q

What is the difference betweenletandconst?

A

Const cannot be reassigned
Const must be initialized during declaration
(Let can be updated but CANNOT be re-declared, const also cannot be re-declared)

18
Q

Why is it possible to.push()a new value into aconstvariable that points to anArray?

A

Because the you can still change a const variable’s property values

19
Q

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

A

Use let if you know the variable will need to be reassigned

20
Q

What is the syntax for writing a template literal?

A

Wrapping text with back ticks
Let msg = this text can span multiple lines;

${} for substitutions

21
Q

What is “string interpolation”?

A

The ability to substitute parts of a string for values of variables or expressions

22
Q

What is destructuring, conceptually?

A

Syntax shortcut for assigning properties of an object/elements of an array to individual variables.

23
Q

What is the syntax forObjectdestructuring?

A

let { property1: var1, property2: var 2 } = objectName;

24
Q

What is the syntax forArraydestructuring?

A

const arr = [1, 2, 3];
const [ var1, var2, var3 ] = arr;

25
Q

How can you tell the difference between destructuring and creatingObject/Arrayliterals?

A

Creating object/array literal -> object/array literal on right side of assignment operator

Destructuring assignment -> things that looks like an object/array literal on left side of assignment operator

26
Q

What is the syntax for defining an arrow function?

A

(parameters) => { statements }

27
Q

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

A

It will be an expression and you do not need a return keyword