Inheritance between function constructors in JavaScript

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 25

  • @aman12988
    @aman12988 Год назад +1

    Amazing explanation sir🙏🙏..We seriously need this type of soothing simple explanation for Computer Languages

  • @MuraliKrishna-gn7ev
    @MuraliKrishna-gn7ev Год назад +1

    Man, where are you till now. I have 8 years experience in UI development, never saw this much clear explanation. thank you 1/0 times.

  • @balazsbraun1423
    @balazsbraun1423 Год назад +7

    Awesome content, man! I really love this playlist. Learning so much from it. But, correct me if I'm wrong, but I think there's a mistake in this video. If you set Employee.prototype to Person.prototype, and you create a person, like let mike = new Person(...), mike will have all the calcSalary() and the empDetails() in the __proto__, even though mike is not an instance of Employee. Plus, if you want to override a method in the Employee.prototype, it will overwrite it in the Person.prototype, as that is what Employee.prototype is referencing.
    So, it should be
    Employee.prototype = Object.create(Person.prototype);
    This way, Employee.prototype still inherits everything from Person.prototype, but it's a separate object.

  • @spark5364
    @spark5364 2 года назад +4

    At 17.10 why dont we write Emlpoyee= Object.create(person.prototype).

  • @farazk9729
    @farazk9729 Год назад

    Great content; thank you SO MUCH.

  • @_TheGreatOne_
    @_TheGreatOne_ Год назад

    So...this means that we can only make one of this type of inheritance "link?" , as in an object constructor child can only be linked to 1 parent's prototype method and not multiple? I get that the parent will always be 1 but what is there to do in the case of an object constructor having the need to take prototype methods from multiple object constructors and writing that line of code twice will simply overwrite the previous line?

  • @funcomedy2
    @funcomedy2 11 месяцев назад

    Thank you 👏

  • @dyracho6667
    @dyracho6667 2 года назад

    thank you.
    subscribed !

  • @umerfarooq4026
    @umerfarooq4026 3 года назад +1

    Thanks ..sir have u made video on ""super() ""

    • @procademy
      @procademy  3 года назад +1

      In the class inheritance lecture, I have covered super() function. You can check it out.

    • @umerfarooq4026
      @umerfarooq4026 3 года назад

      @@procademy thank you... What is difference between class and object inheritance

    • @procademy
      @procademy  3 года назад +2

      Sorry for the late reply. The main use of a class is that, it acts as a blueprint for creating N number of objects. Lets say, you have Employee class which inherits from Person class. Now when you instantiate 100 objects using this employee class, each of them will inherit methods and properties from Person class also. So, here you will save a lot of time using class inheritance.
      Now let try to do the same thing using objects. So, you have a person object and you want to create 100 employee objects like john, merry, Steve etc. Let's say, these objects should also inherit methods of person object. in order to that, you will have to make each employee inherit from person object one by one explicitly. This is quite cumbersome task right? To make 100 employees inherit from person object.
      Hope this answered your question. have a great day :)

    • @umerfarooq4026
      @umerfarooq4026 3 года назад

      @@procademy thanks

    • @umerfarooq4026
      @umerfarooq4026 3 года назад

      Now I hope will be to understand javascript by watching ur videos

  • @the_wrong_note
    @the_wrong_note Год назад

    Is assigning Employee.prototype = Person.prototype the right way?, Shouldn't it be Employee.prototype.__proto__ = Person.prototype?

  • @xxapoloxx
    @xxapoloxx Год назад

    This isnt inheritance, this is dependency injection handled through reflection.

  • @youusef101
    @youusef101 2 года назад +1

    Thief

    • @farazk9729
      @farazk9729 Год назад

      Why thief?!

    • @youusef101
      @youusef101 Год назад

      ​@@farazk9729 His whole content is stolen from a popular JS course from Jonas Schmedtmann

    • @farazk9729
      @farazk9729 Год назад +1

      @@youusef101 wow! Didn't know that

    • @farazk9729
      @farazk9729 Год назад +2

      @@youusef101 I just checked the course you mentioned on my Udemy Personal Plan; they are not exactly the same. I mean the concepts are the same cos the language is the same! But the examples are different. There are similarities, but I am not sure if those similarities justify calling someone a thief, but again, who knows.. I might be wrong. I need to do more of Jonas's content.

    • @youusef101
      @youusef101 Год назад

      @@farazk9729 I took the course so I can tell

  • @alagumanikandanr8772
    @alagumanikandanr8772 2 года назад

    Thank you 👏