JavaScript Question: How do I Set the Prototype of an Object?

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ธ.ค. 2024

ความคิดเห็น • 18

  • @RaulRodriguez-zq2pt
    @RaulRodriguez-zq2pt 4 ปีที่แล้ว +3

    Thank you for the time you took to make these tutorials. They are really helping me excel in my career

  • @rickyu1978
    @rickyu1978 5 ปีที่แล้ว +4

    Good example, but i think for us beginners we would like to know when in a real life use case would we use prototypes and constructors i have created a couple of complex web apps and never needed to set a prototype or constructor, although i could probably benefit from it, problem is dont know when i need to use it

    • @AllThingsJavaScript
      @AllThingsJavaScript  5 ปีที่แล้ว +4

      Good topic for a future tutorial. One rule that is important is don't repeat code, so if a certain functionality is being used in more than one place, put it on the prototype. You are correct you can do a lot of coding without using prototypal inheritance, but I would encourage looking for places you can use it. It will make your code cleaner and easier to manage and maintain.

    • @rickyu1978
      @rickyu1978 5 ปีที่แล้ว

      @@AllThingsJavaScript Thanks, look forward to that tutorial on use cases.

  • @allenyang201
    @allenyang201 3 ปีที่แล้ว +1

    What keyboard do you have, I like the sound.

  • @thasnibeegum5448
    @thasnibeegum5448 6 ปีที่แล้ว +5

    more useful ..Thank you

  • @NoOne-om9bb
    @NoOne-om9bb 6 ปีที่แล้ว +2

    Sir with ur tutorials is it possible to get a job, don't mind me but I m low on money can't afford udemy or udacity etc but ur courses are incredible, could u please advice?

    • @AllThingsJavaScript
      @AllThingsJavaScript  6 ปีที่แล้ว

      Sure, you can learn JavaScript well enough to start working in. It will just take a bit more effort on your part.

    • @NoOne-om9bb
      @NoOne-om9bb 6 ปีที่แล้ว

      All Things JavaScript, LLC I got it sir thank you very much, God bless u for helping us👍🏻

  • @dyunior
    @dyunior 5 ปีที่แล้ว

    How about ES6 class functions?

    • @AllThingsJavaScript
      @AllThingsJavaScript  5 ปีที่แล้ว +1

      By default ES6 classes assign methods to the prototype. It is a simple way to set up the prototype. Although I feel it obscures the true nature of what is going on. I talk about this a bit in my latest tutorial: th-cam.com/video/iYCT1dY42d8/w-d-xo.html

  • @nickdhrones6425
    @nickdhrones6425 7 ปีที่แล้ว

    Method #1 has a dysfunctional prototype. It is missing a required constructor property.
    The better solution would be to just mutate the constructor functions existing prototype object.
    Greeting.prototype.greet = function() {...}
    Or you could add ...
    objProto.constructor = Greeting
    to objProto object.

    • @Zhang_Nicolas
      @Zhang_Nicolas 6 ปีที่แล้ว

      NickD Hrones 虽然不懂你在说什么,但是感觉好强大的样子。Although I don't really understand what you are saying, but I feel it is great(My poor translation for that Chinese online saying expressing sort of awesome yet hard to understand).

    • @Zhang_Nicolas
      @Zhang_Nicolas 6 ปีที่แล้ว

      I am reading a book, your solution is quite alike. The book is hard for me so I search the video tutorial but it turns out your reply is adding the help, thx. By the way, I am reading Secrets of the javascript ninjia, 2nd.

    • @Zhang_Nicolas
      @Zhang_Nicolas 6 ปีที่แล้ว

      I am reading a book, your solution is quite alike. The book is hard for me so I search the video tutorial but it turns out your reply is adding the help, thx. By the way, I am reading Secrets of the javascript ninjia, 2nd.

  • @seenuvasanv
    @seenuvasanv 7 ปีที่แล้ว +1

    Nice..

  • @Pareshbpatel
    @Pareshbpatel 3 ปีที่แล้ว

    {2021-09-23}