Reactjs Interview Question
1. What is JavaScript Call Back ?
Sol: A Call Back is Function Passed as an argument to another Function.
2. What is Promises in JavaScript ?
Sol: Promises were introduced in the ES6 version in 2015. It Contain Producing Code and Consuming Code .
3. What is Difference Let and Var ?
Sol: (a) Let is a Block scope and Var is Function Scope.
(b) Let does not allowed Redeclared variables and
Var allows to Redeclared variables.
(c)Let is Featured of Es6 and Var is ECMAScript1 Feature.
(d)Hoisting is not allowed in Let and Hoisting is allowed in Var.
4. What is a closure in java script ?
sol: Closure is a inner function that can access the outer function variables as well as global variables.
5. what is a difference between function component and class components.
sol: IN function components
1. use hooks
2.use props as argument
3.create java script simple function
4. NO life cycle
5. NO constructor
6. use return statement
In Class Components
1. use life cycle
2. use constructor
3. use this.props
4.render function to return
5.NO Hooks
6. whata is a useState ?
Sol:
1. Its a hook.
2. use it is function component
3. To track state , state is like data or properties.
7. what is jsx.
sol:
extension of java script.
we use jsx to create user interface.
we can write html in java script .
browser can't read jsx , So babel is a compiler to convert jsx to regular java script code.
8. Differece settimeout and setinterval.
Sol:
settimeout: only on time.
setinterval: again and again a specified time.
9. NPM and YARN
sol: pakage Manager hai dono . yarn fast hai .
10. What is a flux ?
Sol: not a library not a framework.
Redex is a more advanced version of flux/
Unidirection data flow and solve mvc issues.
Flow :
Dispathers -> action -> stores ->view
11. What is a javaScript Event Listner ?
sol: ek button p ek s jayda event ko add karan .. Event Listner hota hai .
12 . Array Reverse
sol: Show Reverse Value of array .
13. What is use of Refs ?
sol: Using useRefs hook we can handle dom element manipulation.
is se box ki text value or
14. what are props in React js ?
Sol:
<Header title="php tutorial " autor= "shishir sharma" />
In funciton
props.title
In class
this.props.title
15. Controlled and Uncontrolled Component in React js ?
Sol:
Controlled : Form data handled by React component means using useState. recommended by React.
Uncontrolled : Form data handled by dom.
16. What is Hooks in reactjs.
sol: Hooks are functions that introduce in reactjs 16.8
useState
useReducer
useEffect
useRef
useCallback
useMemo
17. What is a Props dilling ?
Sol: Props dilling is a situation when we passing some data to every level and our requirement is for final level component so we are unnecessary passing data.
avoid this issue .
1. Redux
2. context Api
3. component composition
18. What is a shallow copy and deep copy in js ?
Sol: Shallow Copy :: Copy only top level elements.
Deep Copy :: Copy top level and nested level .
19. What is event loop in JavaScript ?
Sol: javaScript single-threded programming Language .
js is a run time Model.
run on a task time.
20. JavaScript Rest Operator ?
Sol: Packs the element into Array.
21. java script spread Operator ?
22. Using Destruring
Sol: const names = ['Rajesh', "mukesh ", "Priya"];
const [name1,name2,name3] = names;
console.log(name1);
23. Virtual Dom and Real Dom difference ?
Sol: follow React in Virtual Dom. and changes in not directly in Browser.
Follow Angular in Real Dom and changes in directly in Browser.
24. What is a sematic UI ?
Sol: Sematic UI used to Build UI very fast and easily .We can also say React ui Library.
make prograssive Bar.
material ui, Redux.
25. What is the Output ?
let arr = [2,3,5];
console.log(arr); sol: [2,3,5]
console.log(...arr); sol: 2 3 5 (Unpack array )
console.log({...arr}); sol: {0:2, 1:3, 2:5}
26. What is javascript Map function ?
sol: print data of array . and conver in array.
const input = [2,3,5,7];
input.map((number,i)=>(
<div key={i} >{i}</div>
)
)
27. what is js filter ?
sol: create new Array .
28. What is a local storage ?
sol: save value in the browser .
local storage no expiration date.
when browser is close, no data deleted.
localstorage.setItem("username", 'tes');
localstorage.getItem("username");
locastorage.clear();
29.How redux work ?
Sol: Redux is a state management library .
It is a third party library.
It can be used in angular , react ,vu js.
Store: Where we store All states.
Components: Here we are use states.
Action: Type(Increment or Decrement) and Payroll(Data)
Dispatchers: Dispatch() is a method used to dispatch actions and trigger state changed to the store.
Reducer: Here we can write logic to change the states.
30. What is javascipt entries ?
sol: return key and value of array . doesn't change original Array .
const input= [2, 3, 5, 6];
const arr = input.entries();
for (let x of arr){
console.log(x);
}
31. What is a javaScript IndexOf ?
sol: This method return of first index of value and if value not fount than return value -1.
const input = [2, 3, 4, 5,];
let outArray = input.IndexOf(5);
console.log(outArray);
32. What is js forEach ?
sol: This method call a function for each element in Array . If array is empty then not executed.
33. What is a Output ?
Sol:
Show () {
a = 10;
let b = 20;
};
show();
console.log(a); sol: 10
console.log(b); sol: error .... let is a Block scope.
.. if inside console then show value .
34. What is a useReducer ?
Sol: useReducer Hook is similar to the usestate Hook.
useReducer (reducer, initial state)
useReducer Hook return current state and a dispatch method.
35. What is Memozation ?
Sol: Speed up application by caching.
javascript
useMemo Hook
36. What is a Higher order components ?
Sol: It is a component .
It takes another component as an argument .
It returns a new component.
37. Life cycle method in React js.
Sol: Each Component Has three phases.
Mounting: Putting Element in Dom.
Updating: Updating a Component.
Unmounting: Remove from Dom.
38. What is a Redux Thunk ?
Sol: Redux thunk is a middleware .It is a function that return a another function. And the purpose of middleware is to intercept an action before it reaches the reducer.
Instead of sending the action to the reducer directly.
First it will go to middleware by thunk and if need some change like type , payload then do it then pass to reducer.
39. What is a Lexical Scoping ?
Sol: In the inner function we can access the variable of the outer function.
the child function is seen to have lexically bound the parent function. It also called static scoping.
40. Pure funciton in javaScript ?
Sol. That accept argument and return value .
It is depend upon what argument are you passing.
It does not modifying any value.
it's output does't get affected by other values and state
41. Pure Component ?
Sol. Pure Component is similar to the component but It skip re-render for some state and state.
pure component is a subclass of Component.
class Greeting extends PureComponent {
render(){
return <h1> Hello, {this.props.name}</h1>;
}
}
42. Pure component in function Component ?
Sol: React.memo is a higher order component that takes react component as its first argument and return a pure react component .
43. Unidireciton data flow in Reactjs ?
Sol: Means One way data binding.
parent to child.
44. How to pass data child to parent component ?
sol: using props
45. How many ways to call API in Reactjs ?
Sol: 1. XLMHttpRequest
2. Fetch Api
3. Axios
46. What are the advantage of using Redux js with reactjs ?
Sol: centralized state management system That is Store.
Easy to dubug.
Optimization .
Storing long term-data
Great Supportive community.
47.
Comments
Post a Comment