Skip to content

Conversation

@mao-sz
Copy link
Contributor

@mao-sz mao-sz commented Sep 4, 2025

Because

Due to some inconsistencies with code style and usage of comments, some learners miss some things or get confused in the lesson flow when some parts are in normal text and some parts are in longer comments.

There has also been common confusion regarding the point of IIFEs or what IIFEs actually are (perhaps due to focusing immediately on a practical use of IIFEs without giving a more plain example of what an IIFE really just is - people sometimes overthink it's some special specific construct).

This PR

  • Tweaks code blocks
    • Reorganises comments so that key lesson text is now normal text, with those code blocks split for easier following
    • Uses more consistent formatting across lesson (should better match other lessons too)
  • Rephrases ESM note box to more clearly link it with the lesson's section topic
  • Adds some clarifying content on definition and purpose of IIFE to cover some gaps in the current explanations

Issue

Closes #29212

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project curriculum contributing guide
  • The title of this PR follows the location of change: brief description of change format, e.g. Intro to HTML and CSS lesson: Fix link text
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If any lesson files are included in this PR, they have been previewed with the Markdown preview tool to ensure it is formatted correctly
  • If any lesson files are included in this PR, they follow the Layout Style Guide

Some code blocks split to be easier to follow than trying to follow
large comments
Style is more consistent with the rest of the curriculum as well.
Heading added as now required by style guide.
Rephrased to link general concept of modules with the current lesson
section.
Addresses common confusion with "why not just call the factory function
once and omit the IIFE?"
Common confusion that IIFEs are a special construct and not just a func
exp called immediately (due to immediate focus on the module pattern).

The module pattern doesn't have to be used with factory functions only,
just it's one of the more useful use cases.
@github-actions github-actions bot added the Content: JavaScript Involves the JavaScript course label Sep 4, 2025
@rlmoser99 rlmoser99 requested review from a team and JustWaveThings and removed request for a team September 8, 2025 00:56
@mao-sz mao-sz marked this pull request as draft September 10, 2025 14:47
Copy link
Contributor

@JustWaveThings JustWaveThings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I'll have a little deeper think about this section and repurpose this PR as more content clarification with a side of tidyup, rather than the reverse.

That sounds like a solid plan. I think your example code above is an improvement as well. Thanks for doing this Mao.

@mao-sz mao-sz marked this pull request as ready for review November 1, 2025 02:50
@mao-sz
Copy link
Contributor Author

mao-sz commented Nov 1, 2025

I don't have a huge amount of time right now but plan to rework the currying/closure section (as discussed above) in a separate PR in the next few days, or after this PR gets merged.
I think it's out of this PR's scope and I'd rather not block these changes with that section.

Design pattern not the main focus here and singleton stuff isn't expanded on in this lesson.
Avoid a terminology-based rabbit hole.
@mao-sz mao-sz requested a review from ManonLef November 17, 2025 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content: JavaScript Involves the JavaScript course

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Factory Functions: Suggested style tidy-up and phrasing tweaks

4 participants