Fullstack Open 1 Flashcards
How do you prevent a website from caching content such as images and JavaScript while developing?
In the developer console go to the network tab and tick the checkbox for “Disable cache”
In a response header what unit of measurement is content-length?
content length is the size in bytes.
content-length: 89635
The response size is 89635 bytes.
Why is content-type an important response header?
It tells the browser what to do with the response.
content-type: image/png
// render this as an image
content-type: text/html; charset=utf-8
// render this as HTML
What is the DOM?
Document Object Model, or DOM, is an Application Programming Interface (API) which enables programmatic modification of the element trees corresponding to web-pages.
You send a POST request to the server and it responds with HTTP status code 302. What does this tell the browser to do?
Status code 302 is an URL redirect, with which the server asks the browser to do a new HTTP GET request to the address defined in the header’s Location.
Response Headers
Location: /notes
How many HTML pages does a SPA (Single-page application) consist of?
SPA-style websites don’t fetch all of their pages separately from the server, but instead comprise only one HTML page fetched from the server, the contents of which are manipulated with JavaScript that executes in the browser.
What is JSX compiled into?
JSX is compiled into JavaScript.
Is it possible to write React as “pure JavaScript” without using JSX?
Yes, It is possible to write React as “pure JavaScript” without using JSX. Although, nobody with a sound mind would actually do so.
A core philosophy of React is composing applications from many what ?
A core philosophy of React is composing applications from many specialized reusable components.
Does using a React fragment render an element?
No it does render an element.
What is the official name of the JavaScript standard?
The official name of the JavaScript standard is ECMAScript
Browsers do not support all of JavaScript’s newest features, what is the solution to this? What is the most popular tool for doing this?
Code run in browsers has to be transpiled from a newer version of JavaScript to an older, more compatible version. Today, the most popular way to do the transpiling is by using Babel.
How do you open the Node.js console and what can you do in it?
Use the command “node”
You can write JavaScript Code inside it.
What is a cool way to exit the Node.js console?
type .exit
In React code, it is preferable to use the array method concat to the push method, why?
concat returns a copy of the array with the new value added. concat does not mutate the original array.
What is this an example of
const t = [1, 2, 3, 4, 5]
const [first, second, …rest] = t
what will first second and rest contain
Destructuring assignment
console.log(first, second) // 1, 2 is printed
console.log(rest) // [3, 4, 5] is printed
What is an object literal?
An object literal is created by listing the objects properties within braces:
const object1 = {
name: ‘Arto Hellas’,
age: 35,
education: ‘PhD’,
}
What can cause this output from a console.log()
“props value is [object Object]” and how would you avoid it?
using the concatenation operator
console.log(“props value is “ + props);
To avoid it log multiple arguments to console.log( )
console.log(“props value is “, props);
What is a higher order function?
Functions that use other functions as arguments or return functions are named higher-order functions.
// uses a function that is passed as an argument
function iUseFunction(func) {
return func();
}
// Returns a function from a function
function iReturnFunction() {
return function() { return 42 };
}
What are first order functions?
Functions that use only primitives or objects as arguments, and only return primitives or objects are named first-order functions.
Can a function be a value and what does that even mean?
Yes a function can be a value (the value of a variable). This means you can store a function in a variable and do stuff with it like pass it as an argument to a higher order function.
const hiFunction = function() {
return ‘Hello!’
};
the value of hiFunction is:
function() {
return ‘Hello!’
};