What three things are on the start-line of an HTTP request message?
What three things are on the start-line of an HTTP response message?
What are HTTP headers?
Where would you go if you wanted to learn more about a specific HTTP Header?
MDN Web Docs ! :D
Is a body required for a valid HTTP request or response message?
– nope
What does the new operator do?
- uses constructor function to make new instance of object, vs var newObj = obj.create(ogObj);
What property of JavaScript functions can store shared behavior for instances created with new?
What does the instanceof operator do?
– it checks if the object is a product of the given constructor function
tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object. returns boolean
What is a “callback” function?
A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.
Besides adding an event listener callback function to an element or the document, what is one way to delay the execution of a JavaScript function until some point in the future?
– .setTimeout(func, delay)
How can you set up a function to be called repeatedly without using a loop?
- - clearInterval(intervalID)
What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?
– 0, meaning execute immediately/next cycle
What do setTimeout() and setInterval() return?
a numeric, non-zero value which identifies the timer created by the call to setInterval()
What is AJAX?
What does the AJAX acronym stand for?
– the term Ajax is now used to
refer to a group of technologies that offer asynchronous functionality in the browser
Which object is built into the browser for making HTTP requests in JavaScript?
– XMLHttpRequest
What event is fired by XMLHttpRequest objects when they are finished loading the data from the server?
- - progress, error, abort, timeout, etc
An XMLHttpRequest object has an addEventListener() method just like DOM elements. How is it possible that they both share this functionality?
- - inherits from eventTarget
explain:
var $userList = document.querySelector(‘#user-list’);
var xhr = new XMLHttpRequest();
xhr.open(‘GET’, ‘https://jsonplaceholder.typicode.com/users’);
xhr.responseType = ‘json’;
xhr.addEventListener(‘load’, function () {
console.log(xhr.status);
console.log(xhr.response);
for (let i = 0; i < xhr.response.length; i++) {
const newItem = document.createElement(‘li’);
newItem.textContent = xhr.response[i].name;
$userList.appendChild(newItem);
}
});
xhr.send()
…