Showing posts with label Reactjs. Show all posts
Showing posts with label Reactjs. Show all posts

Friday, April 8, 2022

React- UI Architect Interview Questions

Javascript
  1.  Difference between for each and map
  2. Pair check with String or array like 
    input = Hello and output should be {H:1, e:1, l:2, o:1}
    OR [10, 40, 20, 40, 30, 20, 40, 10] output in pair count 
  3. React performance 
  4. Prev props in function component 
  5. Render Props in react 
  6. Solid Principle 
======================
    Angular Architect Interview 
  1. How TO create Dynamic form in Angular 
  2. Micro frontEnd in Angular 
  3. Project estimation scenario Like if you have requirements under discussion and you need to give some timeline ,
  4. Project proposals 
  5. What All NFRS you should have for FE

Monday, July 19, 2021

How JavaScript works: Event loop and the rise of Async programming

 What is the Event Loop?

We’ll start with a somewhat of an odd claim — despite allowing async JavaScript code (like the setTimeout), until ES6, JavaScript itself has actually never had any direct notion of asynchronicity built into it. The JavaScript engine has never done anything more than executing a single chunk of your program at any given moment.

For more details on how JavaScript engines work (Google’s V8 specifically).





So, who tells the JS Engine to execute chunks of your program? In reality, the JS Engine doesn’t run in isolation — it runs inside a hosting environment, which for most developers is the typical web browser or Node.js. Actually, nowadays, JavaScript gets embedded into all kinds of devices, from robots to light bulbs. Every single device represents a different type of hosting environment for the JS Engine.

The common denominator in all environments is a built-in mechanism called the event loop, which handles the execution of multiple chunks of your program over time, each time invoking the JS Engine.

This means that the JS Engine is just an on-demand execution environment for any arbitrary JS code. It’s the surrounding environment that schedules the events (the JS code executions).

So, for example, when your JavaScript program makes an Ajax request to fetch some data from the server, you set up the “response” code in a function (the “callback”), and the JS Engine tells the hosting environment:
“Hey, I’m going to suspend execution for now, but whenever you finish with that network request, and you have some data, please call this function back.”

The browser is then set up to listen for the response from the network, and when it has something to return to you, it will schedule the callback function to be executed by inserting it into the event loop.

Tuesday, November 6, 2018

React Components in loop

How to create dynamic react component in loop

state={

  Userinfo:[

    { name: 'Ravish Jha', Location: 'India'},

    { name: 'Ritika Jha', Location: 'USA'},

    { name: 'Raju Jha', Location: 'UK'}

  ]

} 
 
render() {
return (
<div className="App">
{
this.state.Userinfo.map(info => {
return <Useroutput UserName= {info.name}
UserLocation
={info.Location} />
})}
</div>
);
}
 

Thursday, December 14, 2017

React toggle Class Name on click

getInitialState: function() {
    return {
      myclass: "ravish"
    }
  },
  handleClick: function() {
var temp="ravish";
if( this.state.myclass=="ravish"){
  temp="ravish open"
}
this.setState({
      myclass: temp
    });


<div id="change button" className={this.state.myclass} onClick={this.handleClick} ></div>