{{ message }}
fix(curriculum): correct WeakSet example with valid references#66981
Open
yoehae wants to merge 3 commits intofreeCodeCamp:mainfrom
Open
fix(curriculum): correct WeakSet example with valid references#66981yoehae wants to merge 3 commits intofreeCodeCamp:mainfrom
yoehae wants to merge 3 commits intofreeCodeCamp:mainfrom
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
majestic-owl448
requested changes
Apr 20, 2026
Contributor
There was a problem hiding this comment.
please update the output snippet below to be
WeakSet {{…}, {…}, {…}}
[[Entries]]
0: value: {name: 'Mopane Tree'}
1: value: {name: 'Baobab'}
2: value: {name: 'Breadfruit'}
[[Prototype]]: WeakSetand the paragraph "The contents appear empty because WeakSets are not iterable and do not expose their contents directly."
to
The contents are visible here because the object variables still hold strong references, keeping those objects in memory. Keep in mind that WeakSets are not iterable, so there is no way to loop over their entries or access them programmatically. What you see in the output is only a debugging aid.
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Checklist:
mainbranch of freeCodeCamp.Closes #66982
Update the
WeakSetexample to pass object variables totreeWeakSet.add()instead of object literals, and to pass an object variable totreeWeakSet.has()instead of a string..add()leaves no variable bound to the added object, so there is no way to reference it later. A subsequent.has()call with a literal that looks identical will still returnfalse, because each literal evaluates to a distinct object andWeakSetcompares entries by reference identity.WeakSetholds only weak references, an object added via a bare literal has no remaining strong reference once the statement completes, making it eligible for garbage collection and liable to disappear from the set before any later check..has()always returns false, becauseWeakSetcan only store objects. Strings are not valid entries.Note: resubmitting after a previous web-UI PR was deprioritized. Verified locally in a Codespace with
FCC_BLOCK='lecture-working-with-maps-and-sets'pnpm run develop, confirmed the corrected code renders on the lesson page.Opened a tracking issue at #66982 and linked it in the description. Will wait for triage before expecting review.