Mod 1 -2 Flashcards
What are function expressions?
function expressions are a syntax structure that allow for simple functions to be written anonymously or with an arrow function:
- let sayHi = function() {
alert( “Hello” );
}; - x => x%2
They can even be assigned to a variable
List all JS data types
-numbers
-boolean
-string
-symbol
-special
-object (includes arrays)
What are the 4 parts of an HTTP response?
Hypertext Transfer Protocol Response
- Status line
(HTTP/version status-code reason-phrase) - Response headers
- Blank line
- Body (w/ resource)
What are the 4 parts of an HTTP request?
Hypertext Transfer Protocol Request
- Request Line
(Request method Resource Http/version) - Request Headers
- Blank line
- Body (additional data)
What are the 6 parts of a URL
Uniform Resource Locator
- Scheme
- Server name
- Port number
- Path to resource
- Query parameters
- Anchor
What are the 3 components of a URL?
Uniform Resource Locator
- Scheme or protocol
- Hostname
- Resource name
What is CSS?
Cascading Style Sheet
A method used for describing the presentation and style of webpages while HTML is used for structure
Allows customization for screen size
What is HTML?
Hypertext Transfer Protocol
A markup language to describe web documents.
The client interprets HTML from an HTTP response in order to display a web document.
In JS, what is a free variable?
In javascript closures, free variables are simply the variables that the function takes (read and write) in the enclosing scope where is declared the closure or in a parent scope.
Look at this real world example :
Gol.prototype._ensureInit = function() {
…
var _this = this;
var setDim = function() {
_this.w = _this.canvas.clientWidth;
_this.h = _this.canvas.clientHeight;
_this.canvas.width = _this.w;
_this.canvas.height = _this.h;
_this.dimChanged = true;
_this.draw();
};
setDim();
window.addEventListener(‘resize’, setDim);
…
};
In this example a closure points from the setDim function towards the variable _this declared in the enclosing scope (the _ensureInit function). This variable isn’t declared in setDim nor passed. It’s a “free variable”.
In JS, what is a closure?
A closure is a function having access to the parent scope, even after the parent function has closed.
In other words, a closure gives you access to an outer function’s scope from an inner function or to a free variable.
In JS, what is a constructor look like?
The constructor method is a special method of a class for creating and initializing an object instance of that class.
class Polygon {
constructor() {
this.name = ‘Polygon’;
}
}
const poly1 = new Polygon();
In JS, what is a higher order function?
Higher order functions are functions that take one or more functions as arguments, or return a function as their result
// Callback function, passed as a parameter in the higher order function
function callbackFunction(){
console.log(‘I am a callback function’);
}
// higher order function
function higherOrderFunction(func){
console.log(‘I am higher order function’)
func()
What is HTML?
HyperText Markup Language is the language used to describe the structure and meaning of webpages.
HyperText refers to documents that link to one another.
The other piece is that it is a Markup Language. This means that it is basically a language to describe webpages. This is distinct from a programming language that allows for the use of logic and control structures.