Front End Flashcards
Name 3 ways to decrease page load speed
- Reduce Image Size, 2. Minify and combine files, 3. Minimize HTTP requests
What does Doctype do?
Informs the browser of the type and version of HTML
What are data- attributes good for?
The data attribute allows us to store extra information on HTML elements eg the position of an element
What is Javascript?
A client side and server side scripting language understood by web browsers
Why would you use a srcset attribute in an image tag
To select which image source to used based on criteria such as page width or pixel density
What is CSS selector specificity and how does it work?
Specificity is the means by which browsers decide which css rules to apply. Type < Class < Id
Can you explain the difference between px, em and rem as they relate to font sizing
Px are pixels as on the screen, em is relative to the font size of the element, Rem is relative to the font size of the element
Provide a use case for a pseudo class
:hover, :focus, to change styling on hover or focus
Explain Event Delegation
Using event.target so that if we have a lot of elements handled in the same way we can put a single event handler on a shared ancestor
Explain how this works in javascript
Refers to the context where it is revoked
Explain how prototypal inheritance works
prototypical inheritance refers to the ability to access object properties from another object. We use a JavaScript prototype to add new properties and methods to an existing object constructor.
Whats the difference between a variable that is null, undefined or undeclared?
null is a defined value, undefined means the variable had been declared and not given a value, undeclared means the variable has not been declared and will throw an error
What is a closure
A function enclosed within another function thats revoked immediately within the function
What language constructions do you use for iterating over object properties and array items?
While, for, do while, for in, for of
Difference between forEach and .map
Map returns the altered array while foreach returns undefined, you can chain methods onto map
What is a javascript method?
Actions that can be performed on objects
What are the JS data types
String, number, boolean, object, undefined
What’s the difference between var, let and const
Var declarations are globally scoped or function scoped while let and const are block scoped, bock scoped is typically wherever you see curly brackets {if, loops etc}. Var can be updated and redeclared, let can be updated but not redeclared, const variables can be neither updated or redeclared.
Explain Hoisting
In Javascript, a variable can be used before it’s been declared
Whats the difference between an attribute and a property?
Attributes are defined by HTMLand are constant. Properties are defined by Javascript and are variable
What is the difference betwen “==” and “===”
== checks equality without taking type into account, === takes type into account
Explain the difference between synchronous and asynchronous functions
Synchronous code is executed in sequence – each statement waits for the previous statement to finish before executing. Asynchronous code doesn’t have to wait – your program can continue to run.
Can you offer a use case for the new arrow => function syntax? How does this new syntax differ from other functions?
An arrow function doesnt define its own this value, a regular functions this value is dependent on how it is invoked
What is the definition of a higher-order function?
A function that accepts or returns another function
What is spread syntax
Allows an iterable such as an array or object to be expanded const numbers = [1, 2, 3];
console.log(sum(…numbers));
What is a promise, how would you use one?
A promise represents the eventual completion or failure of an asynchronous behaviour. If fulfilled a then method can be called and if not fulfilled a catch method can be called.
let myPromise = new Promise(function(myResolve, myReject) { // asynchronous request
myResolve(); // when successful
myReject(); // when error
});
What is the difference between a while and a do-while loop?
A while loop checks the condition before an iteration of the loop, do while checks the condition at the end of an iteration
Define an object
A data structure consisting of key value pairs and methods
Define the DOM
The document object model is a cross-platform interface that treats HTML document as a tree structure where each node is an object representing part of the document
What is HTML?
Standard markup language for web browsers
What is CSS?
CSS is a style sheet language for describing the presentation of a document written in a markup language