JavaScript Map

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • new Map([iterable])
  • map.set(key, value)
  • map.get(key)
  • map.size
  • map.clear()
  • map.delete(key)
  • map.entries()
  • map.keys()
  • map.values()
  • map.forEach(callback[, thisArg])

Parameters

ParameterDetails
iterableAny iterable object (for example an array) containing [key, value] pairs.
keyThe key of an element.
valueThe value assigned to the key.
callbackCallback function called with three parameters: value, key, and the map.
thisArgValue which will be used as this when executing callback.

Remarks

In Maps NaN is considered to be the same as NaN, even though NaN !== NaN. For example:

const map = new Map([[NaN, true]]);
console.log(map.get(NaN)); // true


Got any JavaScript Question?