entries() Function is used to return an Array iterator object with key and value pairs.
Let us say, we have a Array that contains five names, Mohan, Kriti, Philip, Salim and Andrew. And we want to get the index as well as its values.
<html> <body> <script> var x = ["Mohan", "Kriti", "Philip", "Salim", "Andrew"] var y = x.entries() for(i of y) { document.write(i, "</br>") } </script> </body> </html>
So, we have an Array that has 5 names.
In the above Array, the indexes are the Keys ad its actual values are the values. And entries() function exactly does that. It extracts key and value and stores it in variable y.
var y = x.entries()
Now, if you see the output, there are both keys and values.
0,Mohan 1,Kriti 2,Philip 3,Salim 4,Andrew