Is there any advantage to use Map.has() for checking if key exists in Map instead of using Map.get()? (Other than code readability reasons)
I checked ES2015 language specifications and both methods seems the same except the return value so I believe the performance is the same but maybe there are some other aspects I don't know of that could affect performance here.
Map.prototype.has ( key )
The following steps are taken:
Let M be the this value. If Type(M) is not Object, throw a TypeError exception. If M does not have a [[MapData]] internal slot, throw a TypeError exception. Let entries be the List that is the value of M’s [[MapData]] internal slot. Repeat for each Record {[[key]], [[value]]} p that is an element of entries, If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, return true. Return false.
Map.prototype.has method specification
Map.prototype.get ( key )
The following steps are taken:
Let M be the this value. If Type(M) is not Object, throw a TypeError exception. If M does not have a [[MapData]] internal slot, throw a TypeError exception. Let entries be the List that is the value of M’s [[MapData]] internal slot. Repeat for each Record {[[key]], [[value]]} p that is an element of entries, If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, return p.[[value]]. Return undefined.