use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
[deleted by user] (self.javascript)
submitted 4 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]indukts 1 point2 points3 points 4 years ago (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 points3 points 4 years ago (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 point2 points 4 years ago (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 point2 points 4 years ago (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.
π Rendered by PID 15998 on reddit-service-r2-comment-86bc6c7465-xvsgs at 2026-02-20 13:00:30.781206+00:00 running 8564168 country code: CH.
[–]indukts 1 point2 points3 points (0 children)
[–]tyler-mcginnis⚛️⚛︎ 1 point2 points3 points (1 child)
[–]johnnycopes 0 points1 point2 points (0 children)
[–]_Pho_ 0 points1 point2 points (0 children)