16.18: Polymorphism in JavaScript - Topics of JavaScript/ES6

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

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

  • @wepranaga
    @wepranaga 5 лет назад +77

    I wish you had a podcast. I'd listen to it all day :))

  • @jhack89
    @jhack89 5 лет назад +2

    Cristal clear explanation! I will definitely be watching your other videos on ES6 classes. Once I saw your video I suddenly felt the concept of ES6 OOP is simple and I could clearly see how it mimics the way things work in languages like C++ and Java also in polymorphism. Still, there are very few tutorials mentioning how it works as explicitly and in detail, and I always had doubts. Thank you so much!
    I can really feel that you care about us understanding, and that makes the whole difference! By the way, your code is super clean! I really like your style of coding, and I will make a point of learning from it.

  • @lindascoon4652
    @lindascoon4652 5 лет назад +3

    Never seen anyone more excited about OOP. I feel excited now.

    • @entalpa
      @entalpa 5 лет назад +1

      Use TypeScript if you want to be more excited :)

    • @TheCodingTrain
      @TheCodingTrain  5 лет назад

      😂

  • @leandroaraujo4201
    @leandroaraujo4201 5 лет назад +40

    1:35 That was a great way to correct your mistake haha, I was wondering how you would fix that mistake during the livestream. Btw this video was interesting to watch!!! I like the way you teach, and explain things. I wish I was your student hehe.

    • @MFBA
      @MFBA 5 лет назад +4

      you are

  • @benjaminoechsle2091
    @benjaminoechsle2091 5 лет назад +7

    Dan, you are such a wonderful teacher. I love watching coding train videos and learning so much from you. Keep up your fantastic work and your nice spirit. The coding train is by far the best channel on youtube! :)

  • @0xTim
    @0xTim 5 лет назад +26

    *Type Systems*
    In languages such as Java, a variable must be *explicitly* given a type, e.g. _int num = 42;_ in other languages, such as Python, the type is *implicitly* determined using type inference, e.g. _num = 42_ ( _num_ has type _int_ ).
    With *static* typing, the type of a variable is already known at compile time. In the Java example above, the compiler already knows that num has the type _int_ . In a *dynamically* typed language, on the other hand, type checks only happen at runtime.
    If a language treats types strictly it is *strongly* typed as opposed to *weakly* typed. A relevant characteristic is whether data types are implicitly converted. In JavaScript, for example, the comparison _2=="2"_ gives _true_ ( *weak* ), while _2==="2"_ gives _false_ ( *strong* ). In the first case, the types are converted accordingly.
    EDIT: *See also GetrundeltHD's comment*

    • @djtygre
      @djtygre 5 лет назад

      no one cares about type casting. he runs loose. if you prefer the C++ environment, declare yourself. it's a common comment, and super annoying, strict, ridiculous, etc. the whole thing he built avoids this banality of this classist syntax, some things to consider when you make your own speech. you can build you own programs bro!

    • @djtygre
      @djtygre 5 лет назад

      also. use python since you like it so much pretty simple syntax huh? i use python to control rasp pi. sort of a crap language to processing but hey, get strict.

  • @andrewkiminhwan
    @andrewkiminhwan 5 лет назад +2

    leave it to Daniel to simple explain concepts like this that have evaded my grasp for years

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

    excellent work. I come from a Java background and your explanation cleared me from many misconceptions. Thank you So MUCH

  • @lukasluftlaufer1093
    @lukasluftlaufer1093 4 года назад

    mind = blown! What a cool idea to inherit the vector class this way!

  • @shogunz
    @shogunz 5 лет назад +1

    Thank you man now with all your tutorials I can code

  • @kathanshah5613
    @kathanshah5613 5 лет назад +2

    You are making my day very creative
    Thanks alot

  • @SimonTiger
    @SimonTiger 5 лет назад

    Compilers
    C: Compiled to machine code beforehand, and then run.
    Python / JavaScript: Interpreted as it's run, and executed that way.
    Java: Very confusing. It's compiled down beforehand, but not to machine code. But to an intermediate language called ByteScript. Then, that ByteScript code is interpreted and executed.

  • @yves2522
    @yves2522 4 года назад +1

    Just amazing how you explain things...You're great ;-)

  • @cani8846
    @cani8846 5 лет назад +2

    I love your es6 videos

  • @limitless1692
    @limitless1692 4 года назад

    The way thatt you corected yourself with that clip was pretty wow i mean WOW :)

  • @getrundelthd9807
    @getrundelthd9807 5 лет назад +5

    I think you've made a mistake with your explanation of strongly typed. Strongly typed does not mean that the type of a variable has to stay the same during the programs execution. This behaviour refers to statically typed and in fact Java is statically typed so you can't change a variables type but in Python you can so Python isn't statically typed. Strongly typed means you can't treat the same location in memory as the same type. In Python you can't do that you have to convert variables so that you can treat them as a different type because you have no direct memory access via pointers. Same holds for Java. In C you have pointers and you can cast e.g. a string pointer to an int pointer. That means you can treat the same location in memory as 2 different types and therefore C is weakly typed.

    • @seancpp
      @seancpp 5 лет назад

      +1 underrated comment

    • @TheCodingTrain
      @TheCodingTrain  5 лет назад +4

      Ah, thank you for this. Excellent clarification and explanation! I wish I could pin two comments! If you'd like to write this up somewhere I could link to it from the description? Or perhaps I should make a follow-up video to go through all these terms:
      * strongly vs weakly
      * static vs dynamic
      * explicit vs implicit

  • @flat9safety
    @flat9safety 5 лет назад +1

    Awesome video. Thanks Daniel!

  • @seddikibelgacem2393
    @seddikibelgacem2393 5 лет назад +2

    Thank you shiffman your the best

  • @olgamazurenko8142
    @olgamazurenko8142 5 лет назад

    Super understandable. Thank you a lot!

  • @miscellaneous9932
    @miscellaneous9932 5 лет назад +2

    This is gold!

  • @adarshsoni5323
    @adarshsoni5323 5 лет назад +1

    Please make in depth course on JavaScript

  • @m.b786
    @m.b786 5 лет назад

    crystal clear ! give that to my stud

  • @DawutMuhammetgurbanow
    @DawutMuhammetgurbanow 9 месяцев назад

    Why you dont explaining about your last video codes. You are showing them but i dont know what do some methods of your code of last video.

  • @oussamasethoum2755
    @oussamasethoum2755 4 года назад

    i can't seem to find a way to make encapsulation in ES6 using the class keyword !

  • @giorgibatsiashvili4270
    @giorgibatsiashvili4270 5 лет назад +1

    More JS OOP Stuff please Sensei

  • @kiwi1361
    @kiwi1361 4 года назад

    I love you, thank you for explaining this

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

    wow, if you thought these videos were incredible the first time. try a second time some time later.

  • @stevegalili355
    @stevegalili355 5 лет назад

    Great video Dan!!

  • @Itscheho
    @Itscheho 5 лет назад

    Just wanted to mention that polymorphism can also refer to polymorphic functions/methods which is something implemented in javascript as far as i know.

    • @TheCodingTrain
      @TheCodingTrain  5 лет назад

      Oh, thank you!

    • @Itscheho
      @Itscheho 5 лет назад

      @@TheCodingTrain oh just realized after seeing you reply that i have a typo there.. Should be "... something NOT implemented..."

  • @grainfrizz
    @grainfrizz 5 лет назад +1

    Everything extends Object. #life

    • @leandroaraujo4201
      @leandroaraujo4201 5 лет назад

      Yes, you can also say:
      class blahblahblah extends null {}
      doing so, clears the object's prototype

    • @kiwi1361
      @kiwi1361 4 года назад

      except death

  • @GuilhermeBorgesCunha
    @GuilhermeBorgesCunha 5 лет назад

    Question: on Java, if wanted to use polymorphism, would I need to declare two methods with the Override statement? I noticed that on JavaScript you haven't to implement two methods, you used exactly the same.

    • @oofusmcdoofus
      @oofusmcdoofus 5 лет назад

      Watch the processing videos on polymorphism

  • @slyer7695
    @slyer7695 5 лет назад +1

    Love from Italy!!!! ❤️❤️❤️❤️ 🇮🇹 #LoveFromItaly9

  • @HHJoshHH
    @HHJoshHH 7 месяцев назад

    🔥

  • @princeshukla3095
    @princeshukla3095 5 лет назад

    Very useful video

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

    The guy is amazing! =)

  • @tahsincesur1927
    @tahsincesur1927 5 лет назад

    i can feel my brain got bigger 👌👌

    • @kiwi1361
      @kiwi1361 4 года назад

      i can feel your brain getting bigger too (?)

  • @diogoalmeida762
    @diogoalmeida762 5 лет назад

    Hi!
    i'm making a litlle game in processing...But i got a problem that is i dont know how to set the coordinates to be the same on every monitor type using fullscreen...like in a 1920x1080 the coordinates are different from a 1600 x 900.
    Can anyone help?

    • @BoJaN4464
      @BoJaN4464 5 лет назад

      If you're doing UI, think of the UI elements as being "attached" to a side of the screen. For example, if you want an ammo indicator in the bottom right, draw it at {x: screen.width - ammo.width, y: screen.height - ammo.height} so instead of being relative to the top left(0,0) it's now relative to the bottom right(width,height)
      You can also treat your screen coordinates as being between 0 and 1 and then multiplying them by width and height but then you have to deal with scaling and it's honestly a huge hastle.

  • @davidascholer
    @davidascholer 4 года назад

    Not sure why, but him jumping into the screen w him in the background kinda freaked me out.

  • @Gaprop
    @Gaprop 5 лет назад

    At around 7:00 when you wrote
    this.vel = p5.Vector.random2D();
    Couldn’t you have said
    this.vel = super.random2D();
    instead?

    • @TheCodingTrain
      @TheCodingTrain  5 лет назад

      Great question! random2D() is actually a "static" function so is called by the class name itself.

  • @MegaMadness
    @MegaMadness 5 лет назад +1

    Hey, could you make a new Vector tutorial for p5?
    Thanks!

    • @oofusmcdoofus
      @oofusmcdoofus 5 лет назад

      Watch the processing videos theyre just about the same just the syntax is a bit different

  • @kustomweb
    @kustomweb 5 лет назад +4

    Function isAppreciated(you,byme) { return true; }

  • @5head924
    @5head924 5 лет назад

    Hi i was watching your p5 series on 3:3 you show how to do key pressed and I was wondering how I get that to to work on a specific key. Help from anyone would appreciated 😃

    • @TheCodingTrain
      @TheCodingTrain  5 лет назад +1

      if (key == 'a') is for the a key. For more, would you mind asking at discourse.processing.org/! It's a better platform for Processing and p5.js related code questions. You can share code there easily! Feel free to link from here to your post.

    • @5head924
      @5head924 5 лет назад

      The Coding Train ok thank you

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

    Ya I made an qbit thing but it's not stable because I'm at room temperature but it's a physical qbit

  • @HayderAmeenDoctor
    @HayderAmeenDoctor 4 года назад

    AMAZING VIDEOES

  • @kingykronous2284
    @kingykronous2284 5 лет назад

    Is that a double upload? I need to start learning to keep up
    Well, really I still haven't really learned to make a simple game, just some moving shapes, but still...

    • @TheCodingTrain
      @TheCodingTrain  5 лет назад

      Save this for later, you don't need it now if you are just starting out!

    • @kingykronous2284
      @kingykronous2284 5 лет назад

      @@TheCodingTrain Yeah that's true. I also have a question. Which would you recommend for a beginner, p5js or processing 3?
      I have learned a little in p5js but it's not a problem to instead learn java and use processing 3.
      I've heard sometimes that java is a great beginner language, especially if you want to learn something like C# and the fact that processing 3 has it's own program rather than needing one for writing code. Javascript has been pretty simple for me and easy to learn especially with your channel and the p5js reference library.
      Edit: Too late I've switched you can't stop me now

    • @kingykronous2284
      @kingykronous2284 5 лет назад

      I'd also like to say that your tutorials are great for beginners and being able to talk with you, ask you questions makes your channel a lot better.

  • @lumschente
    @lumschente 5 лет назад +2

    Accidentally liked, but it's ok xD

  • @uovo
    @uovo 5 лет назад

    i enjoy your videos more than the stupid dumb videos i watched before i discovered your channel, that is impressive

  • @jonathan-._.-
    @jonathan-._.- 5 лет назад

    polymorphism in javascript seems kinda useless oO ? i mean you could jsut push any object into the array that has a show and update function and it would still work its not like javascripthas such a thing as typed arrays

  • @grainfrizz
    @grainfrizz 5 лет назад

    Publish in 2:1 please?

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

    Pls be ok

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

    I noticed that you had a longer neck and rounder face in the other video -- both cute, don't get me wrong. That's right, I got side-tracked.

  • @alinawaz4034
    @alinawaz4034 5 лет назад

    first

    • @lumschente
      @lumschente 5 лет назад

      Nice, I hope you enjoy it.

  • @Pizzaguy2
    @Pizzaguy2 5 лет назад

    can u adopt me ?

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

    I want to be a good girl