JavaScript entries() | Convert an Array to an Iterator Object

The JavaScript entries() method returns an object Array Iterator that will obviously in key/value pairs. For example:

HTML with JavaScript Code
<!DOCTYPE html>
      const a = ["Berlin", "Vancouver", "Tokyo", "NYC"];

      const b = a.entries();
      for(let x of b)

The snapshot given below shows the sample output produced by above JavaScript example:

javascript entries

Note - The for...of loop is used to loop through the values of an iterable object.

JavaScript entries() Syntax

The syntax of entries() method in JavaScript is:


JavaScript Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube