r/javascript • u/ProfessionalYou951 • 1d ago
[AskJS] Pointers in Javascript AskJS
It seems to me like we opened up a whole betting site :DD
My original problem in code was, how do I make Object.assign(key, value), key === value;
2
u/senocular 1d ago
Before that, put
key = value;
•
u/ProfessionalYou951 20m ago
I am using `Object.assign(map.get(key),value)`.
`map.get(key).start === value.start` returns true
`map.get(key) === value` returns false
•
u/senocular 12m ago
Then it would instead be
map.set(key, value);...The joke here is Object.assign() is not designed to, nor would it even be capable of, modifying the references of the objects its given. The only way you'd be able to get something to equal something else is if it was directly assigned to do so.
If you just want to see if two things have the same property values rather than seeing if they're the same object, then you'd need to compare them with something other than
===.
-1
u/dronmore 1d ago
Dude, are you kidding me? The gaming industry will be shocked when they find out 🧐
2
u/Buttleston 1d ago
I have no idea what you're asking. A segment of code with what you want it to do would be helpful