Interview Questions Flashcards

1
Q

What is React?

A

React is a Javascript framework/library. It lets you create UI’s from small isolated pieces of code called components, that can each have their own state.

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

What is Redux?

A

Redux is state management library that’s most commonly used with the React library.

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

How does Redux work?

A

Redux works by having a central store, that holds all of your applications state. Each component can have access to the state, without having to pass props up or down through components.

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

Redux setup process

A

Create a store that’ll hold your state and all your reducers, create reducers that’ll take in an action and change your state based on action, create actions that’ll pass payload and action to your reducers.

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

What are reducers in Redux?

A

Reducers in Redux are functions that take in two parameters: state/initial state, and an action. Based on what action is passed to the reducer, the reducer will then update the state and return a new state.

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

Why do you choose React?

A

In React you can create highly reusable components that can be used in different parts of a project.
Development time is quick, since there’s a lot less boilerplate setup needed.

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

What is AJAX?

A

Ajax is used to communicate with a server to send or receive data.

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

What is responsive design?

A

Responsive design is designing an application or website to be able to render correctly on different sized devices. So that it’ll look nice for the end user whether it be a phone or computer.

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

What is Restful API?

A

A Restful API is a web application that follows the REST principles of architecture.

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

What is the difference between REST API and RESTful API?

A

The Rest Api refers to the rule that can make an Api restfu. A RESTful API is an api that follows those rules that are part of the REST architecture.

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

What is the point of RESTful api?

A

The point of creating RESTful API’s is that it standardizes a set of rules that are used in many web services/applications to send and receive data and requests.

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

What is closure?

A

A closure is an inner function that has access to an outer functions scope.

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

What is a promise?

A

A promise is placeholder for a success value or failure reason, it is used in asynchronous methods that’ll return a value at some point in the future.

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

What is a callback?

A

A function that takes another function as a parameter, and uses that taken in function to complete some task.

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

What are the major features of React?

A
  1. React uses a virtual DOM that compares components previous states, and only updates the items whos state has changed, instead of rerendering/updating all of the components.
  2. React makes use of reusable components, that can be reused as many times throughout a project as needed.
  3. Unidirectional data flow- data flows in a downward pattern from parent to child.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is jsx?

A

Jsx is an extension of React. It allows us to insert html into javascript, instead of the other way which is traditionally how it was done.

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

what is the virtual DOM? How does it work?

A

The virtual DOM is a copy of the real DOM. It works by rerendering the Virtual copy anytime data/state is changed, it then calculates the differences between this DOMand the previous dom. Once the calculations have finished the real DOM is updated with only the components/parts that have changed.

18
Q

State versus Props

A

State are variables that are local to a component that can then be passed to other components(child components) that then become props that they can use.

19
Q

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

A

Lifting up the state means having one common ancestor or parent that holds state and that state is true value of all the data. We do this to maintain data consistency across different components.

20
Q

Why do we set a key property when we map over an array in React?

A

The main purpose is to help React distinguish between elements, and to help rendering when changing an element (changed, added, or removed.

21
Q

What are the core principles of Redux?

A
  1. Single source of truth​ The global state of your application is stored in an object tree within a single store.
  2. State is read-only. The only way to change the state is to emit an action, an object describing what happened.
  3. Changes are made with pure functions​ called Reducers;
22
Q

How do I make an Ajax request using redux?

A

You can make an ajax/ asynchronous request by using redux-thunk, which is middleware that allows you to do these requests in Redux.

23
Q

What are the benefits of using Redux DevTools?

A
  1. Allows you to inspect each payload for status and action
  2. You can “cancel” actions going back in time
  3. If the gearbox code is changed, each action will be evaluated again “in stages”
  4. If the reducers launch then the error and the action in which it happened can be identified
  5. With the persistState () store enhancer, you can preserve debugging sessions on page reloads.
24
Q

How do I use React DevTools? What does this help me with?

A

With React Developer Tools and the console, it is possible to modify rendered React components. This allows you to experiment with changing component values, calling methods, and testing interaction between components.

You can access and update a component’s state and props inside the Components tab.

25
Q

How does React use closures?

A

React uses closures in the same way that JavaScript does. Variables that are local to a function live with the function as long as they are ‘alive’. Except closures are useful in react when props change and rerendering happends. Not all parts of a component need to be rerendered. Those that do get new props given to them when they change, and the older components will still reference the old values since closure encapsulates those values at the time of function creation.

26
Q

What is redux-thunk?

A

Redux-thunk is a middleware that allows you to make asynchronous requests within redux.

27
Q

React context vs redux?

A

Context or Context API is a integrated into React core. This is a lightweight state management system compared to redux. There is way less setup and is easier to learn as there are fewer concepts. Although it is used for state management it’s better to use it for specific components: ex: passing props from parent to deeply nested child. Redux is better for having all your variables globally. Redux should be used for more complicated applications that have many components that all need to communicate with one another. But if it’s a simple project Context API is the way to go.

28
Q

What’s the benefit of using async/await?

A
  1. Code is cleaner and easier to read.
  2. Creates asynchronous code that behaves synchronously.
  3. It ensures that we are returned something, if we were to get data from a server, it’d pause the code until we receive a success, pending, or failure
29
Q

What is a cookie? Cookies vs local storage vs session stoarge?

A
30
Q

What is prototypal inheritance?

A

The Prototypal Inheritance is a feature in javascript used to add methods and properties in objects. It is a method by which an object can inherit the properties and methods of another object.

31
Q

What is the DOM?

A

The Document Object Model (DOM) is a programming interface for web documents.
It represents the page so that programs can change the document structure,
style, and content. The DOM represents the document as nodes and objects;
that way, programming languages can interact with the page.

32
Q

How to copy an array?

A

You can copy an array by assigning it to a variable and using the spread operator.

33
Q

How to compare two objects?

A

We can compare two objects by first stringifying them .Json objects and the comparing them with ===. This will turn all the properties of the object into a json format allowing us to compare.

34
Q

What is asynchronous programming and why is it important in Javascript?

A

Asynchronous programming is having multiple threads running if you have a task that’ll take a larger amount of time. While your asynchronous code is running, the rest of your code won’t be blocked, it’ll continue to run while. Improving performance of your application/website.

35
Q

What is hoisting?

A

Hoisting is during compile time, variables are brought to the top of the page and read. This only applies to variables. You can use a variable before it’s declared in your document, because it will be ‘hoisted’ to the top during compile time. This does not work with native functions like console.log(x); and then declaring var x; afterwards.

36
Q

What is apply, call and bind?

A

They are all predefined methods in javascript.
Call
- you can invoke this method by specifying an owner object.
- you can invoke a method that belongs to another object.
- you can pass arguments to methods, one by one.

Apply
- Is similar to the call method. The only difference is that you can pass an array as the argument instead of one by one.

Bind
- This method returns a function where the value of this keyword is bound to the owner object.

37
Q

Let vs Var vs Const

A
  1. variables that are declared using var are scoped to the function. If it is created outside the function, then it becomes a global variable.
    - var can also be used/referenced in code before they are declared.
    - redeclaring the same variable with var will not throw an error
  2. let and const are block scoped. they can only be accessed within the nearest set of curly braces.
    - you cannot reference a let or const variable before they have been declared in code
    - let lets you reassign it’s value, while const does not.
38
Q

What s the difference between a variable that is: null, undefined or undeclared? How would you go about checking for any of these states?

A

a null variable is equal to nothing, an undefined variable is one that has not been given a value, and an undeclared variable hasn’t been created yet.

39
Q

What is higher order function?

A

A higher order function is any function that takes one or more functions as an argument, which it uses to operate on some data, and/or returns a function as a result.

40
Q

What is the difference between == and ===?

A

== is a loose equality comparison, so if you were to have a var = 2, if we compare it to the string “2” or two it’ll still be the same because it doesn’t check the type of the variable. === operator is strict, so the variable when comparing has to be of the same type and value.

41
Q

What is the difference between store and reducer?

A

Store - Is what holds all the data your application uses.
Reducer - is what manipulates that data when it recieves an action.

42
Q

How do you send data up from child to parent component?

A

You can send data up from a child to parent using a callback function to pass that data.