Set entries() JavaScript

The JavaScript Set entries() method gives an object of Set iterator that contains an array of [value, value] for each element. As there is no concept of key in a set that’s why value and key are the same.

Note: The iterator object maintains the insertion order.

Syntax:

setObj.entries()

Return:
An iterator object that contains an array of [value, value] for each element in the specified Set.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
var jewels = new Set();
jewels.add("DIAMOND").add("GOLD").add("PLATINUM").add("SILVER");
var gems= jewels.entries();
for (let i of gems) {
document.write(i+"<br>"); }
</script>
</body>
</html>