Front End questions Flashcards

1
Q

What is React?

A

React is a JS library used for building interactive user interfaces. It is also the most popular and widely used front-end tool.

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

What is Javascript?

A

JS is a scripting language used to create and control dynamic web content. It is synchronous, blocking, and single-threaded in its most basic form. Single-threaded means it can only do one thing at a time.

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

What is JSX?

A

An HTML-like syntax extension of Javascript. It allows us to write HTML elements in JS and place them in the DOM without the need of using createElement() and appendChild(). This HTML like synatx is converted into JS objects using a transpiler like Babel

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

What is the virtual DOM

A

React creates a Virtual DOM which is a copy of the actual DOM. Any time a change is made or state changes in the application, a new virtual DOM is created and compared to prev virtual DOM. The actual DOM then updates only those objects that were changed in the virtual DOM. Virtual DOM leads to improved performance and faster applications.

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

What makes Redux special?

A

Because state is stored in a central location, it makes it easier to understand where errors are occurring thus easier to debug issues. Also, access to Redux dev tools, and handy middlewares like redux thunk and redux persist

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

What are reducers in redux?

A

A reducer is a slice of the entire pie that is the application’s state. It is a function that takes in an initial state and a set of various actions. Depending on the action that is dispatched, the state living in the reducer will be altered in a certain manner. The reducer gets exported and imported into the rootReducer which makes up the Redux store.

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

Why did you choose React?

A

I chose React because it is a very popular and highly-regarded web technology. Based on my research it seemed to be a less complicated and more beginner friendly JS library/framework, especially when compared to Angular. Moreover it is incredibly powerful due to the various libraries and packages that can be installed to assist you in development.

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

What is AJAX?

A

Stands for asynchronous javascript and XML. It is used to make a request to a server in which JSON is the commonly used format for receiving the server data. Fetches are made using XMLHttpRequests. Can use fetch and axios to make AJAX requests which return a promise.

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

What is Restful API

A

Restful API simply refers to an API that adheres to the constraints of a REST API.

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

What is a REST API?

A

A REST API conforms to a particular set of criteria:

  1. A client-server architecture in which client requests are made via HTTP. The response format from making this request is typically in JSON (JS Object Notation)
  2. Stateless communication between client and server. All state is maintained on client side
  3. Layered system in which the architecture is composed of hierarchical layers that is not visible to the client
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the major features of React

A
  1. Reusable components
  2. Virtual DOM
  3. Unidirectional Data flow
  4. JSX
  5. Important extensions like Redux for state management and various other useful libraries that make development easier.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the DOM?

A

Document Object Model is a tree-like structure interface that represents how the HTML is read by the browser. It can be manipulated, re-structured, and styled with a scripting language such as JS.

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

What is State?

A

State is an object that is used to contain data or information about a specific component. When the user interacts with the page with a particular event, such as a click or key press, the state can change. Depending on the state of the application, the component will behave and render in a certain manner.

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

What are props?

A

Props are useful in React in a few ways. One example is when you create a re-usable component in which the structure will be maintained but the content of the component will be different for each instance, props can be used in each occurrence of the component to specify it. Also, if a component is rendering a child component within it, you can give that child component data.

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

Why do we set a key prop when we map over an array?

A

The key prop establishes a relationship between the component and the DOM element. It helps React understand which elements should be updated and which can stay in tact after a particular change within the component. It is not recommended to use the item’s index as a key due to the fact that the array can change it’s order at some point.

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

What is a promise?

A

A JS object that returns a value which you hope to receive in the future. Promises are well-suited for handling asynchronous operations, such as making a call to an API. 3 states of a promise are pending, fulfilled, rejected. Promise responses can either be handled with .then and .catch method, or by using a try, catch block with async await.

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

How to make AJAX request using Redux?

A

install redux thunk which allows asynchronous operations within redux. Create an action that dispatches different types depending on whether the response was resolved or rejected

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

What is the benefit of using async/await?

A

Easier to read then .then because you are creating variables for the Promise responses. It looks like synchronous code.

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

How to copy an array in JS

A

You can create a new array and use the spread operator to spread all of the values in the existing array to the new array. You can also create a new array in where you map over the existing array and just return the values.

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

null vs undefined vs undeclared?

A
  1. Undeclared means a variable has been declared without the use of var let or const
  2. Null means the intentional absence of any value.
  3. Undefined means a variable has been declared but not given a value (let x) or not declared at all
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is a closure?

A

When a function is defined within another function, the inner function has access to the variables and scope of the outer function even when the outer function has finished executing. The closure is a function that accesses its lexical scope and the variables that live within it even when that function is executed outside its lexical scope. A closure remembers the variables from the place where it is defined, no matter where it is executed.

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

What is lexical scoping?

A

It means the accessibility of variables is determined by the position of the variables inside the nested scopes. It means that inside an inner scope you can access variables living in the outer scope.

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

What does lifting state up mean and why do we do it?

A

Lifting state from a child component back up to the parent component for the parent to utilize. This is done using a callback function. In other words, you can create a function that alerts the state in the parent and pass this function to the child through props. You can then pass the proper arguments to that function in the child to alter the parent’s state.

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

What is a callback function?

A

A callback function is a function that is passed into another function as an argument to be executed later. Common examples include the callback function that is used with an array method such as filter or map, or the function used with a JS eventListener.

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

What is redux thunk?

A

It is a Redux middleware that allows you to do async actions by allowing you to return another function in your action which takes dispatch as an argument and then dispatches the synchronous action after the API call has finished.

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

What is a Redux Middleware?

A

Redux middleware is a function that sits between the action and reducer and can interact with the dispatched action before reaching the reducer function. Used for purposes such as logging(redux-logger) and asynchronous API calls.

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

React Context vs Redux

A

Redux is much more powerful and comes equipped with more tools such as Redux Thunk, Redux Persist, Redux Logger, Redux Saga. I’ve often read that an appropriate use for Context is if you are using Redux solely to avoid passing down props to child components.

28
Q

cookies?

A

Smallest capacity of storage. Accessible from any window. Expiration is manually set. Can be stored on browser and server. Cookies used to send data to a server, so do not use if unnecessary.

29
Q

Local Storage

A

largest storage capacity. Accessible from any window. Never expires. Meant from trivial data to be stored on local side like game scores. Only stored on browser.

30
Q

Session Storage

A

Larger capacity than cookies, smaller than local storage. Only accessible from the same tab. Expires when tab closes. Only stored in the browser.

31
Q

What is asynchronous programming?

A

Asynchronous programming is when we want to do an operation in JavaScript in which the result we are trying to obtain will not be immediately available. Running our code asynchronously means to let the code do multiple things at the same time without stopping or blocking the main thread. Async operations are put into the event/callback queue to wait for the call stack and main thread to finish executing so it does not block code. Asynchronous functions can be handled with callback functions, or with Promises using .then() or async/await.

32
Q

What is hoisting?

A

Hoisting is when the JS engine moves variable and function declarations to the top of the code during the creation phase of the global execution context. They are stored in memory which allows them to be executed before declared. Function expressions and arrow functions aren’t hoisted, meaning they cant be executed before declaration. A function expression will behave similar to a variable in that it will return undefined if executed before declaration.

33
Q

Var variable

A

Var is local (or function) scoped. Var can be redeclared AND updated. Var variables are hoisted to the top of their scope and initialized with a value of undefined. Var is problematic because using the same variable name throughout the code base can result in unintentional bugs.

34
Q

What is JS execution context?

A

When JS engine executes a script it creates execution context. Each execution context has two phases: creation phase and execution phase. Global Execution Context is created and variable and function references are stored in memory during the creation phase. Variables will originally be undefined. During execution phase, JS engine assigns values to variables and executes function calls. For every function call, JS engine then creates a function execution context where it creates an arguments object.

35
Q

Why use Redux Dev Tools?

A

It makes it easier to track where and how state has changed. You can trace actions

36
Q

What is a higher order function?

A

A Higher-Order function is a function that receives a function as an argument or returns the function as output. Examples include Array.prototype.map, Array.prototype.filter which are built into the language.

37
Q

What is scope in JS?

A

Scope defines where variables are available for use.

38
Q

Let variable

A

Let is block scoped, meaning if/else statements and loops. Let can be updated but NOT re-declared. Let declarations are hoisted to the top but unlike var which is initialized as undefined, the let keyword is NOT initialized.

39
Q

Const variable

A

Block scoped. Const cannot be updated OR re-declared. Can update an object declared with const however. ex) greeting.message = ‘blah blah’. Hoisted to the top but not initialized. Must be initialized (given a value) when declared.

40
Q

What is NPM?

A

Node Package Manager. Command line utility to install packages.

41
Q

What is Webpack and Babel?

A

Babel is a JS transpiler that converts older versions of JS code to new ones so it works on all browsers. Webpack is a modular build tool transforms source code of a module.

42
Q

Explain CSS Box Model

A

rectangular layout paradigm for HTML element that consists of the content, padding, border, and margin

43
Q

What is SASS?

A

Syntactically Awesome StyleSheets. It’s a CSS pre-processor that adds power and elegance to CSS. You can use variables and nested rules with it.

44
Q

What is strict mode?

A

With strict mode, you cannot use undeclared variables. And undeclared variable is the following: greeting = ‘hello’

45
Q

What are the JS data types?

A

Primitives: boolean, number, string, symbol, undefined, null. Object is not a primitive data type.

46
Q

What do the break and continue statements do?

A

Break statement is used to exit a current loop. Continue statement continues the loop.

47
Q

What are default parameters in a function?

A

When you specifiy default values for parameters in a function. ex) function multiple(numberOne = 1, numberTwo = 3) {return numberOne * numberTwo}

48
Q

What are default parameters in a function?

A

When you specifiy default values for parameters in a function. ex) function multiple(numberOne = 1, numberTwo = 3) {return numberOne * numberTwo}

49
Q

Synchronous vs Asynchronous programming

A

Synchronous functions wait until each statement in a method has been run before moving onto the next. Asynchronous functions execute each line of code without stopping to wait for a value from a function.

50
Q

Explain CSS Specificity

A

CSS specificity concerns itself with how style rules are applied to an HTML document. Inline-styling and id’s have the highest specificity so those styling rules will reign supreme over classes and element selectors

51
Q

What is an API

A

Application programming interface. It is basically a software intermediary that allows two applications to communicate with each other. An analogy is that an API is the waiter in a restaurant who registers your request for a particular dish, communicates that with the kitchen (which is the server or database), and returns the dish back to you.

52
Q

What happens when we enter a url into our browser?

A

A request goes out to the server and after a response is received the browser interprets the code and displays the web page.

53
Q

How does Redux work?

A

A store is created that hold all of the state of the application. This state lives in different reducers that make up the rootReducer. The rootReducer gets passed into the store. The store wraps the entire application. Actions are functions that can be dispatched throughout the application to cause changed within each reducer, thus altering the state of the application.

54
Q

What is the redux setup process?

A

Import Provider which wraps around the App component in index.js. Provider takes in a store prop. Create the store. Pass in rootReducer and any middlewares such as Redux Thunk. RootReducer is made up of individual reducers. Reducers are specific pieces of state for specific components within the application. Actions can be dispatched to alter the state in the reducers. You can bring in state and actions into components with useSelector and useDispatch.

55
Q

How do you copy an object in JS?

A

You can use spread operator and Object.assign

56
Q

How do you compare objects in JS?

A

using method Object.is()

57
Q

What is prototypal inheritance?

A

All objects that are linked to a certain prototype object can use the methods and properties defined in the prototype. The objects inherit the properties of the prototype.

58
Q

What is ‘this’ keyword?

A

Refers to the specific object that is calling a method from it’s prototype. In the global state, ‘this’ refers to the window object. Created during creation phase of global execution context

59
Q

Give an example of a closure

A

If you have an IIFE (Immediately invoked function expression), often there will be variables and functions defined within it. Inner functions will maintain access to variables defined in the IIFE even when the IIFE is finished executing right when the page renders.

60
Q

What are examples of higher order functions?

A

Addevent Listener (which takes in a callback function)

61
Q

What is the call method?

A

A method used on a function that manually sets the ‘this’ keyword on any function that we want to call. Basically, if you want to use a method defined within an object outside of the object, the ‘this’ keyword originally points to undefined. Using call method, we define the object that we want ‘this’ to point to.

Ex) book.call(americanAirlines, 586, ‘Rabie Nasser’)

62
Q

What is the apply method?

A
Does the same thing as call method but takes in the object that you want 'this' to point to, and an array of arguments. Ex) const flightData=[567, 'Rabie Nasser']
book.apply(americanAirlines, flightData)
63
Q

What is the bind method?

A

A replacement to using call or apply. The easiest way to define ‘this’ keyword for a function. Create a variable that ‘binds’ the function to the object you want ‘this’ to point to.

Ex) const spirit = book.bind(americanAirlines)
spirit(456, 'Rabie Nasser')
64
Q

rem vs em

A

em units for the font-size property will be relative to the font-size of the parent element. rem units sizes will always be relative to the font-size of the root html element.

65
Q

managin state in classes vs fn component

A

In a functional component you use the useState hook. With class components, state is an object and you change it using this.setState

66
Q

css flex vs grid

A

CSS flexbox is designed from providing layouts in only one dimension, and they can be either row or column. CSS Grid can be used to create more complex layouts in 2 dimensions