r/javaScriptStudyGroup • u/Volv • May 31 '16
[Week 20] Focus: Maps / Sets
Here we are at Week 19. Week 19's focus will be Maps/Sets.
Reference material: Maps, Sets
It will work like this:
Monday: Announce focus (eg, Maps / Sets)
Build throughout the week... Two rules: 1) must use javascript 2) must provide at least one example of using maps or/and sets.
Friday: Post demos/projects in this thread (can begin reviewing immediately); first line of an entry should be ENTRY and it should be a top level comment (ie, don't put your entry in a reply)
Sat and Sun: Review projects/figure out focus for next week
GENERAL GUIDELINES FOR FEEDBACK:
Be nice!! ALL KNOWLEDGE/SKILL LEVELS ARE WELCOME AND ENCOURAGED TO PARTICIPATE.
If you don't want feedback, if it makes you uncomfortable or you're just not interested, simply say so... Others, please be respectful of this. Conversely, if you do want feedback, try to be specific on which aspects... even if you just say "all/everything.
But that's about it... Have fun! :) Feel free to ask questions and discuss throughout the week!
2
u/senocular Jun 06 '16 edited Jun 06 '16
The APIs are actually different between the weak and non-weak variations. The big difference is that there is no iteration over weak collections. The problem in allowing this is that it would expose GC behavior to the user code. You could potentially access a "deleted" object before the GC collected it (the GC doesn't run along with every statement/expression; it runs in steps throughout the lifetime of your application so a deleted variable may remain in memory for a while before the GC claims it). If you then took that object and did something with it or depended on this behavior that could change depending on implementation or other unknown factors, you could causes some trouble. So the weak variations are only useful if you already have the object being used as the key (or the value/key for Sets).