Trivia Flashcards
What is HTTP, and how it it different from HTTPS?
- The Hypertext Transfer Protocol (HTTP) is designed to enable communications between clients and servers
- protocol used to transfer data over the web
- insecure and data can be intercepted.
- HTTP is a stateless protocol because each command is executed independently, without any knowledge of the commands that came before it.
- Hyper Text Transfer Protocol Secure
- symmetric key cryptography (like ceasar cypher but more complex) if you know how to encrypt a message you also know how to decrypt it
- asymmetric key cryptography: you can encrypt a message (lock the box) but you can’t decrypt it (open a closed box). In technical speech the box is known as the public key and the key to open it is known as the private key.
- encrypting messages using asymmetric cryptography is slower than using symmetric cryptography, so we only use it to exchange the encryption keys.
https://medium.freecodecamp.org/https-explained-with-carrier-pigeons-7029d2193351
What is the event loop in JS? How does it work?
Every time you call a setTimeout function or do some async operation — it is added to the Event Table. This is a data structure which knows that a certain function should be triggered after a certain event. Once that event occurs (timeout, click, mouse move) it sends a notice. The Event Table does not execute functions and does not add them to the call stack on it’s own. It’s sole purpose is to keep track of events and send them to the Event Queue.
The Event Queue is a data structure similar to the stack. It kind of stores the correct order in which the functions should be executed. It receives the function calls from the Event Table, but it needs to somehow send them to the Call Stack. This is where the Event Loop comes in.
This is a constantly running process that checks if the call stack is empty. Every time it ticks it looks at the Call Stack and if it is empty it looks into the Event Queue. If there is something in the event queue that is waiting it is moved to the call stack. If not, then nothing happens.
What happens when you type in ‘www.google.com’ and hit enter?
- The browser first checks the cache (browser, OS, router, ISP) for a DNS record to find the corresponding IP address of www.google.com. If that doesn’t work, the ISP’s DNS server initiates a DNS query (where multiple DNS servers may be searched) to find the IP address of the server that hosts google.com
- Once found, the browser will initiate a TCP connection w/ the server via a 3 way handshake
- Browser then sends an HTTP request to web server
- Server will handle the request and send back an HTTP response, and the browser displays the content
https://medium.com/@maneesha.wijesinghe1/what-happens-when-you-type-an-url-in-the-browser-and-press-enter-bb0aa2449c1a
*What does it mean for a web page to be responsive?
-
*What is a hashmap? How is it different from a hash table?
-
*What are the differences between XSS and CSRF? What are they?
-
List the key benefits that HTML5 introduced.
In no order: 1). accessibility -it made creating accessible sites easier due to semantics and ARIA, 2) cleaner code - it allows you to write clear and descriptive code, allows u to easily separate meaning from style and content, 3) better interactions and game development - allows u to do most interactive and animated possibilities with canvas tag for example, 4) legacy/cross browser support, 5) Mobile - mobile browsers have adopted HTML5 so creating mobile projects is easy, hence the popularity of responsive design.
https://tympanus.net/codrops/2011/11/24/top-10-reasons-to-use-html5-right-now/
How do media queries work?
Media query is a CSS technique introduced in CSS3.
It uses the @media rule to include a block of CSS properties only if a certain condition is true.
https://www.w3schools.com/css/css_rwd_mediaqueries.asp
What does it mean to be RESTful?
- Representational State Transfer
- a set of design principles for making network communication more scalable and flexible
1. A RESTful system has to operate in the client-server model - A server is a computer that has resources of interest, and a client is a computer that wants to interact with the resources stored on the server.
2. Stateless: Servers and clients do not keep track of each other’s state. Each request is standalone and server does not keep track of past requests. When not interacting, a server has no idea of client’s existence.
3. Uniform Interface: ensures that there is a common language between servers and clients that allows each part to be swapped out or modified without breaking the entire system: 1) Identification of resources: Each resource must be uniquely identified by a stable identifier, meaning it does not change w/ interactions. 2) manipulations of resources thru representations: When a client wishes to make changes to resources, it sends the server a representation of what it would like the resulting resource to look like. The server takes the request as a suggestion, but still has ultimate control. 3) Descriptive messages: A self-descriptive message is one that contains all the information that the recipient needs to understand it. 4) Hypermedia is data sent from the server to the client that contains information about what the client can do next–what further requests it can make
4. Caching: server responses should be labelled as either cacheable or non-cacheable
5. Layered System: there can be more components than just servers and clients. However, each component is constrained to only see and interact with the very next layer.
6. Code on demand (optional): refers to the ability for a server to send executable code to the client
https://codewords.recurse.com/issues/five/what-restful-actually-means
Explain prototypes in JavaScript.
Functions can be used to create class-like functionality in JavaScript; and all functions have a prototype property. That prototype property is somewhat like a class definition in other object-oriented langauge. It is actually an instance of an object and every function in JS (constructor function or not) has a prototype object instance whether u use it or not.
What’s a closure? How are they used?
A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time.
To use a closure, simply define a function inside another function and expose it. To expose a function, return it or pass it to another function.
The inner function will have access to the variables in the outer function scope, even after the outer function has returned.
Give a high level overview of how CSS grids work.
It is a 2-dimensional system, where it can handle both columns and rows.
You would apply CSS rules both to a parent element (which becomes the Grid Container) and to that elements children (which become Grid Items).
You would define a container element as a grid, set the column and row sizes, and then place its child elements into the grid.
How does DNS work?
- A user asks their browser to visit freecodecamp.com
- The browser queries a DNS Resolver (usually their ISP) “where’s freecodecamp.com?”
- DNS Resolver queries the Root servers (which have a big important list that keeps this information) “where is .COM?” Replies with Verisign.
- DNS Resolver then queries Verisign — “where is freecodecamp.com?” Verisign replies with the nameservers ns1.cloudflare.com and the IP address 192.168.178.1
- Hosting servers are queried with the IP address. “Give me the files for IP address 192.168.178.1”
- Website files are delivered and rendered on the page
What lifecycle methods get called in the mounting phase? What are the use cases for each of those methods?
1) componentWillMount
Most Common Use Case: App configuration in your root component.
2) componentDidMount
Most Common Use Case: Starting AJAX calls to load in data for your component.
https://engineering.musefind.com/react-lifecycle-methods-how-and-when-to-use-them-2111a1b692b1
What is TCP? When is it used? How does it work?
- Transmission Control Protocol / Internet Protocol.
- Internet traffic needs to be routed to correct place. Online data has to know where it’s going. TCP/IP is used to do this.
- Once TCP gets the data, it chops it into small chunks called packets where they can individually take quickest route thru internet to where they need to go. TCP puts a header on packet to know its destination and origin and a checklist to make sure no packets are missing.
https: //www.khanacademy.org/computing/computer-science/internet-intro/internet-works-intro/v/the-internet-packet-routers-and-reliability
https: //www.youtube.com/watch?v=PpsEaqJV_A0
What lifecycle methods get called in the update phase? What are the use cases for each of those methods? What method gets called in the unmounting phase?
1) shouldComponentUpdate
Most Common Use Case: Controlling exactly when your component will re-render.
2) componentWillUpdate
Most Common Use Case: Used instead of componentWillReceiveProps on a component that also has shouldComponentUpdate (but no access to previous props).
3) componentDidUpdate
Most Common Use Case: Updating the DOM in response to prop or state changes.
1) componentWillUnmount
https: //engineering.musefind.com/react-lifecycle-methods-how-and-when-to-use-them-2111a1b692b1
What’s an IIFE? When would you use it?
Immediate Invoked Function Expression. An IIFE is a function expression that is called immediately after you define it. It is usually used when you want to create a new variable scope.
The (surrounding parenthesis) prevents from treating it as a function declaration.
The final parenthesis() are executing the function expression.
Using IIFE avoids polluting the global namespace.
What is UDP? When would you use it?
User Datagram Protocol
- packets are smaller than TCP
- connectionless - no need establish connection before sending
- more control over when data is sent
Used for multimedia streaming, small transactions (DNS lookups)
https://www.youtube.com/watch?v=Vdc8TCESIg8&t=
Javascript == vs. ===
The identity (===) operator behaves identically to the equality (==) operator except no type conversion is done, and the types must be the same to be considered equal.
== checks for equality with coercion and === checks for equality without coercion — strict equality
What is this in JS? What are some common pitfalls with this?
An object method may need to access the information stored in the object to do its job. To access the object, a method can use the ‘this’ keyword. The value of this is the object “before dot”, the one used to call the method.
What is React?
A js library for building component based UIs
What is recursion? How does it work?
The process in which a function calls itself directly or indirectly is called recursion. The idea is to represent a problem in terms of one or more smaller problems, and add one or more base conditions that stop recursion.
https://www.geeksforgeeks.org/recursion/
Name HTTP methods and short description of each.
GET - The GET method is used to retrieve information from the given server using a given URI. Requests using GET should only retrieve data and should have no other effect on the data (generally). Can be cached.
POST - A POST request is used to send data to the server, and is expected to process that data. Sends data thru body of request.
DELETE - Removes all current representations of the target resource given by a URI.
https://www.tutorialspoint.com/http/http_methods.htm
What is hoisting (JS)?
The behavior of “moving” var and function declarations to the top of their respective scopes during the compilation phase is called hoisting.
Function declarations are completely hoisted. This means that a declared function can be called before it is defined.
Variables are partially hoisted. var declarations are hoisted but not its assignments.
let and const are not hoisted.
https://medium.freecodecamp.org/the-definitive-javascript-handbook-for-a-developer-interview-44ffc6aeb54e
What are pure/impure functions?
Pure functions have no side effects - the return value depends solely on arguments. If you call pure function w/ same set of arguments, you will get same return value - they are predictable. They do not modify the values passed to them.
Impure may call the database or network, may have side effects, may overwrite values passed to them.
What does the ‘new’ keyword in JS do?
Functions invoked using the new keyword are called constructor functions.
So what does the new keyword actually do?
- Creates a new object.
- Sets the object’s prototype to be the prototype of the constructor function.
- Executes the constructor function with this as the newly created object.
- Returns the created object. If the constructor returns an object, this object is returned.