3 ms·
A super quick, simple illustration of the difference, which comes down to the fact that delegation is differential, whereas composition is complete: https://gi
by _getify 13y ago
A super quick, simple illustration of the difference, which comes down to the fact that delegation is differential, whereas composition is complete:
https://gist.github.com/getify/9895188 https://gist.github.com/getify/9895188
For a bit more "real world" of a scenario, you can also compare the `LoginController` / `AuthController` mechanism here, first shown with inheritance+composition, and then shown with simpler OLOO-style delegation:
https://github.com/getify/You-Dont-Know-JS/blob/master/this%20&%20object%20prototypes/ch6.md#simpler-design https://github.com/getify/You-Dont-Know-JS/blob/master/this%...
- jkrems 13y agoAh, thanks. That clarifies things. Neat!