React Js and Redux Questions
# React:
- React is javascript front end library developed by facebook.
- React follows uni-directional data flow.
- In react everything is component and it divides ui in independent piece of code.
# Why to use React Or Features Of React?
- We can make Reusable Components.
- You can re-use components anywhere you need. As a result, (1) your app has consistent look and feel, (2) code re-use makes it easier to maintain and grow your codebase, and (3) it is easier to develop your app. eg. Forms , Wizards
- Virtual DOM: Any view changes are first reflected to virtual DOM, then an efficient diff algorithm compares the previous and current states of the virtual DOM and calculates the best way (minimum amount of updates needed) to apply these changes. Finally those updates are applied to the DOM to ensure minimum read/write time. This is the main reason behind React’s high performance
- Improved performance: React uses virtual DOM, which makes web applications perform faster. Virtual DOM compares its previous state and updates only those components in the real DOM, whose states have changed, rather than updating all the components — like conventional web applications.
- Unidirectional data flow: React follows a unidirectional data flow. This means that when designing a React app, we often nest child components within parent components. And since the data flows in a single direction, it becomes easier to debug errors and know where the problem occurs in an application at the moment.
- Easy creation of dynamic applications as it provides less coding and provides more functionality, whereas, with JavaScript applications, code tends to get complex very quickly.
- Dedicated tools for easy debugging: Facebook has released a chrome extension that we can use to debug React applications. This makes the process of debugging React to web applications faster and easier.
# State and props:
- State are the actual javscript objects which stores the properties and behaviours of the component.
- State values are passed down from parent components to child components in the form of props.
- props are the way of communication between the components.
# Redux thunk :
- Used to handle asyn actions.
- Redux thunk is a middleare that lets u call action creators that returns functions instead of an action object.
- That function receives the store's dispatch method, which is then used to dispatch regular synchronous actions inside the body of the Function once the asynchronous operations have completed.
- Abstraction of html code.
- Html element becomes node in dom.
- Creates a new dom when html element updates.
- Slow.
- DOM manipulation is very expensive
- Too much of memory wastage.
# Virtual Dom:
- Lightweight Javascript object.
- Abstraction of Real dom.
- React Element becomes node in v dom.
- Updates the JSX if element updates.
- Fast.
- DOM manipulation is very easy
- No memory wastage.
# References in react:
- It is an attribute which helps to store a reference to a particular React element or component.
- It is used to return references to a particular element or component returned by render().
# Fetch
- Fetch has no url in request object.
- Fetch request function includes the url as parameter.
- Fetch request is ok when response object contains the ok property
# Axios:
- Axios has url in request object
- Axios request function does not includes the url as parameter.
- Axios request is ok when status is 200
#Redux:
# Switch:
Javascript Questions
- The JavaScript prototype property allows you to add new properties and methods to object constructors.
- function person(first) { this.fName= first}
- person.prototype.nationality = "English";
# promises:
- promises are used to handle asynchronous operations in JavaScript.
- var promise = new promise(function(resolve, reject) {reject('promise Rejected') })
- promise.then(function(successMessage) { }).catch(function(errorMessage) { });
- Definition: Helps you run functions asynchronously, and use their return values (or exceptions) but only once when executed.
- Not Lazy
- Not cancellable( There are promise libraries out there that support cancellation, but ES6 promise doesn't so far). The two possible
- Cannot be retried(promises should have access to the original function that returned the promise to have a retry capability, which is a bad practice)
-
Decisions are
- resolve
- Reject
# Observables
- Helps you run functions asynchronously, and use their return values in a continuous sequence(multiple times) when executed.
- By default, it is Lazy as it emits values when time progresses.
- Has a lot of operators which simppfies the coding effort.
- One operator retry can be used to retry whenever needed, also if we need to retry the observable based on some conditions retryWhen can be used.
# Hoisting:
# Closure:
This function can be better represented by using closures
function A() {
var count = 10;
return function displayGreet() {
console.log(count);
};
}
// Generate the closure
var B= A();
// Use the closure
B();
# Shift method:
# pop method:
# Delete operator:
# unshift method:
# push method:
# What are escape characters :
# What is the use of type of operator:
# What is variable typing:
# Assign value to object properties:
# append value to an array without using push :
# for-in loop:
#for loop :
# call:
# apply:
# Object.values
#Object.keys :
# Functional Components
# Class Components
# let
# const
# var
# forEach loop :
# for loop :
# What is type of null :
# what is undefined:
# Performence Improvements :
#Remove Duplicate Elements from Array:
#array.map method
#array.filter method
# String to Array
#Callback:
Passing the parent method into child and calling the passed method from child on any onlcick events.
# Deprecated Life Cycle Methods
# Local storage
# Session storage
# Cookies
# Props drilling
# HOC
No comments:
Post a Comment