Mixins thumbnail
Mixins
javascript.info
In other words, a mixin provides methods that implement a certain behavior, but we do not use it alone, we use it to add the behavior to other classes. In JavaScript we can only inherit from a single object. There can be only one [[Prototype]] for an object. And a class may extend only one other cla
3 Users
0 Comments
13 Highlights
0 Notes

Top Highlights

  • In other words, a mixin provides methods that implement a certain behavior, but we do not use it alone, we use it to add the behavior to other classes.
  • In JavaScript we can only inherit from a single object. There can be only one [[Prototype]] for an object. And a class may extend only one other class.
  • There’s a concept that can help here, called “mixins”.
  • a mixin is a class containing methods that can be used by other classes without a need to inherit from it.
  • For instance here the mixin sayHiMixin is used to add some “speech” for User:

Tags

Javascript

Ready to highlight and find good content?

Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.