[Go to site: main page, start]

0% found this document useful (0 votes)
4 views2 pages

JavaScript Essentials: Maps, Functions, Sets

The document contains five HTML snippets demonstrating different JavaScript concepts: Maps, Arrow Functions, Spread Operator, Block Scoped Variables, and Sets. Each snippet showcases how to use these features, such as retrieving values from a Map, defining an Arrow Function for multiplication, finding minimum and maximum values using the Spread Operator, modifying a Block Scoped Variable, and creating a Set to store unique values. The results of these operations are displayed in a paragraph element on the web page.

Uploaded by

sthirumalarao24
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

JavaScript Essentials: Maps, Functions, Sets

The document contains five HTML snippets demonstrating different JavaScript concepts: Maps, Arrow Functions, Spread Operator, Block Scoped Variables, and Sets. Each snippet showcases how to use these features, such as retrieving values from a Map, defining an Arrow Function for multiplication, finding minimum and maximum values using the Spread Operator, modifying a Block Scoped Variable, and creating a Set to store unique values. The results of these operations are displayed in a paragraph element on the web page.

Uploaded by

sthirumalarao24
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

1) MAPS

<html>
<body>
<p id="demo"></p>
<script>
const names = new Map([
["abc", 98],
["def", 987],
["ghi", 876]
]);

let num = [Link]("abc");

[Link]("demo").innerHTML = "The number for 'abc' is: " +


num;
</script>
</body>
</html>

2)ARROW FUNCTION

<html>
<body>
<p id="demo"></p>
<script>
const x = (x, y) => {
return x * y;
};
[Link]("demo").innerHTML = x(5, 5);
</script>
</body>
</html>

3)SPREAD OPERATOR

<html>
<body>
<p id="demo"></p>
<script>
const num = [23, 55, 21, 87, 50];
let minvalue = [Link](...num);
let maxvalue = [Link](...num);
[Link]("demo").innerHTML = "Min: " + minvalue + " Max: " +
maxvalue;
</script>
</body>
</html>

4)BLOCK SCOPEDVERIABLE

<html>
<body>
<p id="demo"></p>
<script>
let x = 10;
{
x = 2;
}
[Link]("demo").innerHTML = x;
</script>
</body>
</html>

5)JAVA SCRIPT SET

<html>
<body>
<p id="demo"></p>
<script>
const letter = new Set(); // Create a new Set
[Link]("a");
[Link]("b");
[Link]("c");

[Link]("demo").innerHTML =
"The Set has " + [Link] + " values.";
</script>
</body>
</html>

You might also like