Mixins - Basic JavaScript Fast (28) | Object.assign

Поділитися
Вставка
  • Опубліковано 5 вер 2024
  • In JavaScript, if we want to add functionality of a class, we can get it from another object without establishing inheritance. This pattern is called a mixin.
    Playlist of my JavaScript course
    • [20 hours] JavaScript ...
    Playlist of my HTML5 and CSS3 tutorials
    • [12 hours] HTML and CS...
    Playlist of my algorithm walkthrough
    • Algorithms and data st...
    Playlist of my Java course
    • [14 hours] Java tutori...
    Playlist of my Java examples
    • Java projects for begi...
    #javascripttutorial #javascriptfullcourse #begincodingfast #javascript #mixin #object.assign

КОМЕНТАРІ • 4

  • @Birandoo
    @Birandoo 3 місяці тому +1

    Thank you! This was great. Straight to the point, good definition and easy to understand.
    I was trying to figure out how to use mixins with classes in JS. I tried using other classes as mixins but didn't work the way I wanted to. They either didn't work properly with Object.assign or got overwritten with Object.setPrototypOf. Just making the mixins as objects and using Object.assign works nicely!

    • @BeginCodingFast
      @BeginCodingFast  3 місяці тому

      So glad that my video helped you understand mixins. Thank you for watching my videos too.

  • @sadiqabdullah8457
    @sadiqabdullah8457 Місяць тому

    Aren't Mixin objects? Even the assign method takes target and source(s), all as objects. That means Mixin is an object that uses methods from other object(s).

    • @BeginCodingFast
      @BeginCodingFast  Місяць тому

      In this example, the Object.assign method takes two objects to vary the original class definition. Therefore, it is more reasonable to say that a mixin is a class.