Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   
   HTML   
   CSS   
   JAVA SCRIPT   
   JQUERY   




entries() - FUNCTION


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.

java_Collections

Example :



<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>


Output :



  0,Mohan
  1,Kriti
  2,Philip
  3,Salim
  4,Andrew

So, we have an Array that has 5 names.

java_Collections

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