Interview Questions & Answers

react-js

  • Heart of react components.
  • Must be kept as simple as possible.
  • Determines components rendering and behavior.
  • Creates interactive and dynamic components.
  • Accessed via this.state().

  • Short for properties.
  • Read-only
  • Pure or immutable.
  • Always passed down from parent to child component.
  • Used to render dynamic data.

class MyComponent extends React.Component{
  render(){
    return(
      <div>
        <h1>Hello World</h1>
        <Header/>
      </div>
    );
  }
}
class Header extends React.Component{
  render(){
    <h1>Header Component</h1>
  };
}
ReactDOM.render{
  <MyComponent/>, document.getElementById(‘content’)
};

  • Every component must have a render().
  • It return single react element which is the representation of native DOM component.
  • HTML elements inside render() must be enclosed inside an enclosing tag like <div>.<group>.<form> etc.
  • Should be a pure function .

  • Components are the building blocks of a React application’s UI.
  • Components split up the entire UI into small independent and reusable pieces.
  • JavaScript functions which takes in arbitrary inputs and returns HTML representation.

React –

  • Architecture – Only the view of MVC
  • Rendering – Server-side rendering
  • DOM – Uses virtual DOM
  • Data binding – One-way data binding
  • Debugging – Compile time debugging
  • Author – Facebook

Angular –

  • Architecture – Complete MVC
  • Rendering – Client-side rendering
  • DOM -Uses real DOM
  • Data binding – Two-way data binding
  • Debugging – Run time debugging
  • Author – Google

  • Optional Catch Binding
  • Object.fromEntries
  • Array.flat
  • Array.flatMap
  • Dynamic Import
  • globalThis object

ECMAScript 2016 introduced two new features :-

  • Array.prototype.includes(): It checks the array for the value passed as an argument. It returns true if the array contains the value, otherwise, it returns false.
  • Exponentiation  Operator: ECMAScript 2016 introduced the exponentiation operator, **. It has the same purpose as Math.pow().