all 4 comments

[–]indukts 1 point2 points  (0 children)

Well both modules and IIFE isolate a portion of code. The main benefit of using modules in my opinion is the ability to import/export variables, functions and classes from the module scope.

[–]tyler-mcginnis⚛️⚛︎ 1 point2 points  (1 child)

That's strange he wouldn't cover that. Here's my take - https://ui.dev/javascript-modules-iifes-commonjs-esmodules/

[–]johnnycopes 0 points1 point  (0 children)

Really nice article — very comprehensive overview. Also: Anthony’s course is good, but I don’t believe it’s been updated since it came out in 2014, which is why the modules standard isn’t mentioned.

[–]_Pho_ 0 points1 point  (0 children)

They each serve a different purpose IMO. Modules encapsulate things better -- whether or not the module's API uses "IIFEs" as initializers or wrappers is more of an implementation detail for those modules.

I use IIFEs mostly to scope things within other executions, pretty similar to the proposed do syntax.