Trivia Flashcards
What does it mean to be RESTful?
Representational State Transfer, design principles for making network communication scalable & flexible.
Fielding Constraints:
- Client-Server: network must be made of C’s & S’s
- Stateless: C’s & S’s don’t track each other’s state. Each request is treated as a standalone
- Uniform interface: there is a common language between S and C that allows each part to be swapped out or modified without breaking the entire system
- A: identification of resources: URI’s, communication standard: HTTP
- B: manipulation of resources through representations: sending usually JSON objects
- C: self-descriptive messages: contains all the information that the recipient needs to understand it
- D: hypermedia: data sent from the server to the client that contains information about what the client can do next. HTML is a type of hypermedia
- Caching: server responses should be labelled as either cacheable or non-cacheable
- Layered system: can be more components than just servers and clients, e.g. proxies
- Code on demand: ability for a server to send executable code to the client, e.g.
Explain prototypes in JavaScript
JavaScript is often described as a prototype-based language — each object has a prototype object that acts as a template from which it inherits methods and properties. An object’s prototype object may also have a prototype object, which it inherits methods and properties from, and so on. This is often referred to as a prototype chain, and explains why different objects have properties and methods defined on other objects available to them.
To be exact, the properties and methods are defined on the prototype property on the Objects’ constructor functions, not the object instances themselves.
In classic OOP, classes are defined, then when object instances are created all the properties and methods defined on the class are copied over to the instance. In JavaScript, they are not copied over — instead, a link is made between the object instance and its prototype (its __proto__ property, which is derived from the prototype property on the constructor), and the properties and methods are found by walking up the chain of prototypes.
https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object_prototypes
Key differences between HTML4 and HTML5
- Simplified and Clear Syntax
- Multimedia Elements
- Accessing User Geographical location
- Client Side storage
- Client Server Communication (websockets)
- JavaScript Threading Mechanism
- Browser Compatibility
https://www.webcodegeeks.com/html5/top-10-major-advantages-html5/
List the key benefits that HTML5 introduced.
- Mutuality
- Cleaner markup / Improved Code
- Improved Semantics
- Elegant forms
- Consistency
- Improved Accessibility
- Fulfill the need of Web application
- Offline Application cache
- Client-side database
- Geolocation support
https://www.webcodegeeks.com/html5/top-10-major-advantages-html5/
How do media queries work?
Works by checking the width of the screen accessing the site.
https://www.htmlgoodies.com/beyond/css/introduction-to-css-media-queries.html
What is a JS closure?
A closure is an inner function that has access to the outer (enclosing) function’s variables—scope chain. The closure has three scope chains: it has access to its own scope (variables defined between its curly brackets), it has access to the outer function’s variables, and it has access to the global variables.
The inner function has access not only to the outer function’s variables, but also to the outer function’s parameters. Note that the inner function cannot call the outer function’s arguments object, however, even though it can call the outer function’s parameters directly.
You create a closure by adding a function inside another function.
http://javascriptissexy.com/understand-javascript-closures-with-ease/
Describe variable scope. (JS)
A variable’s scope is the context in which the variable exists. The scope specifies from where you can access a variable and whether you have access to the variable in that context.
Unlike most programming languages, JavaScript does not have block-level scope (variables scoped to surrounding curly brackets); instead, JavaScript has function-level scope. Variables declared within a function are local variables and are only accessible within that function or by functions inside that function. Global scope functions are available to the entire application.
http://javascriptissexy.com/javascript-variable-scope-and-hoisting-explained/
Describe variable hoisting. (JS)
Hoisting describes what happens when the JavaScript engine encounters an identifier, such as a variable or function declaration; when it does this, it acts as if it literally lifts (hoists) that declaration (but not the assignment) up to the top of the current scope.
All variable declarations are hoisted (lifted and declared) to the top of the function, if defined in a function, or the top of the global context, if outside a function.
It is important to know that only variable declarations are hoisted to the top, not variable initialization or assignments (when the variable is assigned a value).
Function declaration overrides variable declaration when hoisted. Both function declaration and variable declarations are hoisted to the top of the containing scope, and function declaration takes precedence over variable declarations, but not over variable assignment.
http://javascriptissexy.com/javascript-variable-scope-and-hoisting-explained/
Describe scope chain. (JS)
When trying to access an identifier in JavaScript, the browser will first look for the variable inside the current scope. If it is not found, the browser will then look in the parent scope of the current scope, and will keep moving up through the parent scopes until it either finds the variable, or reaches the global scope. If the variable still isn’t found in the global scope, the browser will generate a ReferenceError. The nested scopes are known as a scope chain, and this process of checking the current scope and then the parent scopes is known as a variable look-up. This look-up is only able to go up the scope chain, it will never look inside child scopes of the current scope.
http://javascriptissexy.com/understanding-es2015-in-depth-part-1-block-scope-with-let-and-const/
Describe block scope in JS.
Block scope, introduced in ES2015, can be created by using let or const statements inside a block (one or more statements within curly brackets).
Conditional expressions, such as if, for, and while statements, all use blocks to execute statements based on certain conditions.
Block scope means that a block is able to create its own scope, rather than simply existing within the scope created by its nearest parent function, or the global scope. Block scopes work the same as function scopes work, but they are created for blocks, rather than functions.
Describe the two JS phases.
Parsing phase: code is read by the JavaScript engine, which allocates memory for variables and scope creation (hoisting happens here).
Execution phase: code that has been parsed is executed.
Differences between let, const, and var. (JS)
let and var are used to declare mutable (changeable) variables.
const is used to declare an immutable variable; the value cannot be reassigned or redeclared, and it must be initialized with a value. It’s similar to let, regarding the TDZ
let and const have two broad differences from var:
1) they are block scoped
2) accessing a var before it is declared has the result undefined; accessing a let or const before it is declared throws ReferenceError (TDZ). (hoisting)
What is the temporal dead zone (TDZ)? (JS)
Due to hoisting, accessing a var before it is declared has the result ‘undefined’; accessing a let or const before it is declared throws ReferenceError.
The TDZ exists from the moment the scope is initialized to the moment the variable is declared. To fix the ReferenceError, we need to declare the variable before trying to access it.
The TDZ helps to highlight bugs—accessing a value before it has been declared is rarely intentional.
Give a high level overview of how CSS grids work.
CSS grids are used to create a layout/template of a website so that it can still look nice when resized to different viewpoints. Removes superfluous html markups, keeps code cleaner.
Grid stuff:
- container: element containing a grid (display: grid)
- item: any direct descendant of container
- line: row/column lines separating grid into sections
- cell: any cell inside grid
- area: rectangular area (multiple cells)
- track: space between 2 or more lines, row tracks horizontal, column tracks vertical
- gap: empty space between tracks
https://www.sitepoint.com/understanding-css-grid-systems/
What are the steps for DFS vs BFS on a graph?
The depth-first algorithm sticks with one path, following that path down a graph structure until it ends.
The breadth-first search approach, however, evaluates all the possible paths from a given node equally, checking all potential vertices from one node together, and comparing them simultaneously.
What happens when you type “maps.google.com” into the address bar and hit enter?
- The browser checks the cache(s) for a DNS record to find the corresponding IP address of maps.google.com. (4 checks in order: browser cache, OS cache, router cache, then ISP cache).
- If the requested URL is not in the cache, ISP’s DNS server initiates a (recursive) DNS query to find the IP address of the server that hosts maps.google.com.
- Browser initiates a TCP connection with the server. (TCP/IP three-way handshake, sync/acknowledge)
- The browser sends an HTTP request to the web server. (GET request, etc)
- The server handles the request and sends back a response.
- The server sends out an HTTP response.
- The browser displays the HTML content (for HTML responses which is the most common).
in depth: https://github.com/alex/what-happens-when