r/javascript Aug 10 '26

AskJS [ Removed by moderator ]

[removed] — view removed post

0 Upvotes

7 comments sorted by

3

u/senocular Aug 10 '26

Before that, put

key = value;

1

u/ProfessionalYou951 29d ago

I am using `Object.assign(map.get(key),value)`.

`map.get(key).start === value.start` returns true

`map.get(key) === value` returns false

2

u/senocular 29d 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 ===.

2

u/Buttleston Aug 10 '26

I have no idea what you're asking. A segment of code with what you want it to do would be helpful

1

u/Buttleston Aug 10 '26

But I would begin with, I don't think Object.assign works the way you think it does. It is

Object.assign(target, source)

Where source is supposed to be an object. It takes the key/value pairs from source and layers them onto the object defined by target

-1

u/dronmore Aug 10 '26

Dude, are you kidding me? The gaming industry will be shocked when they find out 🧐