JavaScript Map get()

Definition and usage

get() Method used to get the value of a key in the Map.

Instance

// Create a Map
const fruits = new Map([
  ["apples", 500],
  ["bananas", 300],
  ["oranges", 200]
]);
// Get the value of "apples"
let value = fruits.get("apples");

Try it yourself

Syntax

map.get(key)

Parameter

Parameter Description
key Required. The key to be found.

Return value

Type Description
Variable Returns the value of the element found, otherwise returns undefined.

Browser support

map.get() Is a feature of ECMAScript6 (ES6).

Starting from June 2017, all modern browsers support ES6 (JavaScript 2015):

Chrome Edge Firefox Safari Opera
Chrome 51 Edge 15 Firefox 54 Safari 10 Opera 38
2016 May 2017 April 2017 June September 2016 June 2016

map.get() Not supported in Internet Explorer.