Javascript Map has()

Introduction

The Javascript Map has() method checks if a key exists in the Map object.

It returns a boolean value.

myMap.has(key)
  • key - the key to test in the Map object.
let myMap = new Map();
myMap.set('bar', "foo");
console.log(myMap);/*from www  . j a v a 2s.c o  m*/

let a = myMap.has('bar');
console.log(a);// returns true
myMap.has('aKey');
console.log(a);// returns false



PreviousNext

Related