Front End Flashcards

1
Q

Name 3 ways to decrease page load speed

A
  1. Reduce Image Size, 2. Minify and combine files, 3. Minimize HTTP requests
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does Doctype do?

A

Informs the browser of the type and version of HTML

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are data- attributes good for?

A

The data attribute allows us to store extra information on HTML elements eg the position of an element

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Javascript?

A

A client side and server side scripting language understood by web browsers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why would you use a srcset attribute in an image tag

A

To select which image source to used based on criteria such as page width or pixel density

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is CSS selector specificity and how does it work?

A

Specificity is the means by which browsers decide which css rules to apply. Type < Class < Id

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Can you explain the difference between px, em and rem as they relate to font sizing

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Provide a use case for a pseudo class

A

:hover, :focus, to change styling on hover or focus

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Explain Event Delegation

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Explain how this works in javascript

A

Refers to the context where it is revoked

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain how prototypal inheritance works

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Whats the difference between a variable that is null, undefined or undeclared?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a closure

A

A function enclosed within another function thats revoked immediately within the function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What language constructions do you use for iterating over object properties and array items?

A

While, for, do while, for in, for of

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Difference between forEach and .map

A

Map returns the altered array while foreach returns undefined, you can chain methods onto map

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a javascript method?

A

Actions that can be performed on objects

17
Q

What are the JS data types

A

String, number, boolean, object, undefined

18
Q

What’s the difference between var, let and const

A

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.

19
Q

Explain Hoisting

A

In Javascript, a variable can be used before it’s been declared

20
Q

Whats the difference between an attribute and a property?

A

Attributes are defined by HTMLand are constant. Properties are defined by Javascript and are variable

21
Q

What is the difference betwen “==” and “===”

A

== checks equality without taking type into account, === takes type into account

22
Q

Explain the difference between synchronous and asynchronous functions

A

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.

23
Q

Can you offer a use case for the new arrow => function syntax? How does this new syntax differ from other functions?

A

An arrow function doesnt define its own this value, a regular functions this value is dependent on how it is invoked

24
Q

What is the definition of a higher-order function?

A

A function that accepts or returns another function

25
Q

What is spread syntax

A
Allows an iterable such as an array or object to be expanded
const numbers = [1, 2, 3];

console.log(sum(…numbers));

26
Q

What is a promise, how would you use one?

A

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
});

27
Q

What is the difference between a while and a do-while loop?

A

A while loop checks the condition before an iteration of the loop, do while checks the condition at the end of an iteration

28
Q

Define an object

A

A data structure consisting of key value pairs and methods

29
Q

Define the DOM

A

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

30
Q

What is HTML?

A

Standard markup language for web browsers

31
Q

What is CSS?

A

CSS is a style sheet language for describing the presentation of a document written in a markup language