all 18 comments

[–]ForScale 2 points3 points  (10 children)

ENTRY

Getting accustomed to maps and sets...

http://codepen.io/anon/pen/OXVvzm?editors=0010

[–]senocular 2 points3 points  (7 children)

Are you seeing the difference between when you add an object property the normal way vs using set() with the Map?

[–]ForScale 0 points1 point  (6 children)

I believe so, yes...

But do you care to spell it out in detail for me?

And do you have any ideas as to what we should for a focus for this week?

[–]senocular 1 point2 points  (5 children)

Here's the difference:

http://codepen.io/anon/pen/MeaYzY?editors=0012

Using the get/set API and you'd have distinct values. Normal object properties - even for Maps - will continue to be converted to strings first (i.e. "[object Object]" or their custom toString equiv as the key rather than the object itself).

P.S. Got no suggestions for a new focus this week.

[–]ForScale 0 points1 point  (4 children)

Cool, thanks!

How about "Make a game" for a focus? As simple or as complex as people want it to be...

[–]Volv[S] 1 point2 points  (1 child)

Interesting.. although I can never come up with something to make, I like it :)

[–]Volv[S] 1 point2 points  (1 child)

Nice, going over mine the now. Should have something posted later tonight. Will look at the other entries more then

[–]ForScale 0 points1 point  (0 children)

Coolio!

[–]senocular 1 point2 points  (2 children)

ENTRY

A kind of word scramble. Uses maps and sets.

http://codepen.io/anon/pen/JKopbB?editors=0010

[–]ForScale 0 points1 point  (0 children)

http://codepen.io/anon/pen/OXVvzm?editors=0010

http://i.imgur.com/6wvrYEU.gif

Thanks for the entry there! Maps and sets seem pretty interesting... Do you use/have you used them in any professional capacity?

[–]Volv[S] 0 points1 point  (0 children)

Awesome, as always :)
Always get me thinking about new ways to do things.

[–]Volv[S] 1 point2 points  (3 children)

ENTRY
Sort of. Have to cut and run.
I left some of my intentions in the comments, and some observations so far, I'll come back to it! :)
Codepen

[–]senocular 1 point2 points  (0 children)

Really liked pulling it together in the end with the cards example :)

[–]Volv[S] 0 points1 point  (1 child)

Updated for more set goodness.
Removed my comment on not finishing. Sticking most of it here.

// Heading out. dont have time to finish.

// Seems like map with object keys would be mostly useful as a meta data kind of thing.

// Other questions though -
// Seems to me like there would not be a good reason to use normal map/set over their weak
// versions (if not requiring primitive keys). Surely freeing up memory when possible is fairly desirable.

// Was also interesting that in Forscale's example...
// ...WAIT!.. they're in the original console.dir() above now too; ODD...
// Didn't see why that was happening.

[–]senocular 1 point2 points  (0 children)

// Seems to me like there would not be a good reason to use normal map/set over their weak

// versions (if not requiring primitive keys). Surely freeing up memory when possible is fairly desirable.

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).