FIX: Use array to keep best link for each onebox (PR #13717)

Using an object does not work well because HTML elements are cannot be used as keys in all browsers or situations.

GitHub

Wouldn’t it be better to use Map() instead?

I agree with @CvX, looks like Map() would be a better fit here - Map - JavaScript | MDN

TIL about Map. I did not know such thing existed and by the looks of it, it should be always preferred over {}.

by the looks of it, it should be always preferred over {}.

Depends no the use case. Map() is a pretty recent feature in JS and wasn’t available everywhere until not that long ago… So {} was used as a map instead.

until not that long ago…

It’s been available everywhere (even in IE!) for 7 years or more now. :grin:

It’s been available everywhere (even in IE!) for 7 years or more now. :grin:

What now? :exploding_head:

Got that part wrong then :man_facepalming: