<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Map and Set</title>
</head>
<body>
<h2>Set Object</h2>
<script>
// Creating a Set
let mySet = new Set();
// Adding values
mySet.add(1);
mySet.add('Hello');
mySet.add({ key: 'obj' });
// Checking if a value exists
console.log(mySet.has('Hello')); // Output: true
// Iterating through values
mySet.forEach(value => {
document.write(value, `<br>`);
});
</script>
</body>
</html>
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.