4 ms·
Right out of the gate they mention that the first approach listed doesn't clone Symbol...and then they treat this as a flaw. I haven't used Symbol in JS much,
by ubertaco 4y ago
Right out of the gate they mention that the first approach listed doesn't clone Symbol...and then they treat this as a flaw.
I haven't used Symbol in JS much, but I was under the impression that it's _supposed_ to be a sorta "interned" value (in the sense that there exists exactly one instance in existence of each Symbol value)...which would mean that cloning them isn't a concept that makes sense.
My loose awareness of this particular JS type is leaving me quite un-confident in this understanding though, so I'd love for someone to correct me where I'm wrong so I can learn more!
- bottlepalm 4y agoI don't think it's a flaw given a symbol is unique so cloning it wouldn't be possible, and creating a new one would compound the problem by not only removing the symbol, but now adding a new one as well. This article has a pretty good overview of what symbols are, usually a corner case, but good to know - https://medium.com/intrinsic-blog/javascript-symbols-but-why-6b02768f4a5c https://medium.com/intrinsic-blog/javascript-symbols-but-why...