Home » JavaScript Map keys() Method

JavaScript Map keys() Method

by Online Tutorials Library

JavaScript Map keys() method

The JavaScript map keys() method returns an object of new Map iterator. This object contains the key for each element. It maintains insertion order.

Syntax

The keys() method is represented by the following syntax:

Return

A new object of Map iterator.

JavaScript Map keys() method example

Here, we will understand keys() method through various examples.

Example 1

Let’s see a simple example of keys() method.

Test it Now

Output:

1  2  3  

Example 2

Let’s see the same example using for loop.

Test it Now

Output:

1  2  3  

Next TopicJavaScript Math

You may also like