Today I have learned Inhreritance in javascript

 Inhreritance in javascript:

Inheritance is an important concept in object oriented programming. In the classical inheritance, methods from base class get copied into derived class.

In JavaScript, inheritance is supported by using prototype object. Some people call it "Prototypal Inheriatance" and some people call it "Behaviour Delegation".

Let's see how we can achieve inheritance like functionality in JavaScript using prototype object.

Please note that we have set Student.prototype to newly created person object. The new keyword creates an object of Person class and also assigns Person.prototype to new object's prototype object and then finally assigns newly created object to Student.prototype object. Optionally, you can also assign Person.prototype to Student.prototype object.

import React, { Component } from "react";
class Inheritance extends Component {
  render() {
    const { content } = this.props;
return <button> Recruitment:  {content}!</button>;
  }
}
class Test extends Component {
    render() {
      return (
        <div>
         
         <Inheritance content="Recruitment process involves acquisition of work force. Recruitment process begins with identification of vacancy in the organisation after which different steps are undertaken to fill up the vacant position."/>
        </div>
      );
    }
  }
export default Test;
Output:

 
 

Comments

Popular posts from this blog

Building a Full-Stack Student Management System with React.js and NestJS

Today I have solved the problem in javascript

Today I have solved problem in javascript