Object Oriented Programming - Use an IIFE , Module and mixins

Where can I practice using modules, immediately invoked function expression, and “mixin”? I feel like this is extremely useful knowledge for building reusable code and something I should master to work with javascript in a job. I don’t want to just forget this after only doing 1 example problem on Free Code Camp

  • Modules are the primary way of structuring code in JS. But you don’t need to implement them, they’re part of the language. What you’re talking about I think is how they can be implemented by using IIFEs; this is what needed to be done before modules were added and before they had wide support.
  • mixins…yeah I suppose they are used in certain contexts. If the style of programming is class-based (stuff like Angular or Web Components on FE, stuff like Nest on BE then mixins are fairly common, normally implemented using decorators. Not really super common though YMMV.
  • IIFEs have a few very specific usecases (“I have some scoped bit of code that has to execute immediately”). Eg you have a script that needs to pull some data from a web API, can wrap the asynchronous call in an IIFE, it quite neat. But they’re not used very much tbh

All useful concepts, but mainly used as workarounds for deficiencies that have now been fixed

Thank you for your response! I’m added this to my notes

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.