Home  >  Article  >  Web Front-end  >  How to use entries function

How to use entries function

不言
不言Original
2019-02-20 11:19:453295browse

array.entries() is a built-in function in How to use entries function, used to obtain a new Array containing the key and value pairs of each index of the array. Let's look at the specific use of the entries function.

How to use entries function

Let’s first look at the basic syntax of the entries function

array.entries();

It returns an indexed array and the array.entries() function The value of the given array to operate on.

Let’s look at a specific example

The array.entries() method is used to find the key and value pair for each index in any given array.

The code is as follows

<!DOCTYPE html>
<html>
<head>
  <title></title>
</head>
<body>
<script type="text/javascript"> 
var array = ["php", "gfg", "Jhon"]; 
var iterator = array.entries(); 

console.log(iterator.next().value); 

console.log(iterator.next().value); 

console.log(iterator.next().value); 
        
</script> 
</body>
</html>

The execution effect is as follows:

How to use entries function

##This article is all over here, more For exciting content, you can pay attention to other related column tutorials on the PHP Chinese website! ! !

The above is the detailed content of How to use entries function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn