Full-time web dev; JS lover since 2002; CSS fanatic. #CSSIsAwesome
I try to stay up with new web platform features. Web feature you don't understand? Tell me! I'll write an article!
He/him
A, because separate objects are not deduped by a Set, even if they happen to have an identical structure and values. If you wanted it to log B, you'd have to do this:
Top comments (4)
A, because separate objects are not deduped by a Set, even if they happen to have an identical structure and values. If you wanted it to log B, you'd have to do this:
Here the object does get deduped because it's the same exact object instance twice, not two different object instances that looks the same.
A!
This is because in JS Objects are passed by reference instead of value.
Just for fun, one of my first packages on npm was to make a superset of Set that included functionality allows you to do this by reference.
npmjs.com/package/spicy-set
B
A