<!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>Map Object</h2>
<script>
// Creating a Map
let myMap = new Map();
// Adding key-value pairs
myMap.set('name', 'John');
myMap.set(42, 'Answer to the Ultimate Question');
myMap.set({ key: 'obj' }, 'Value for object key');
// Accessing values
console.log(myMap.get('name')); // Output: 'John'
// Iterating through key-value pairs
// myMap.forEach((value, key) => {
// document.write(`${key}: ${value}<br>`);
// });
</script>
</body>
</html>
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.