Home > Web Front-end > JS Tutorial > How to use entries function

How to use entries function

不言
Release: 2019-02-20 11:19:45
Original
3425 people have browsed it

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();
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template