Thursday, February 15, 2024
New JavaScript Set methods, weird HTML line breaks, and Mutation Observer ![](https://mcusercontent.com/42d7a8f52e460525417e7989f/images/7c0c03e2-908b-5ac7-176a-fdef38ec4d8d.png) | Coding puzzleGuess the output! | ![](https://mcusercontent.com/42d7a8f52e460525417e7989f/images/52f89f97-9ddb-8f98-ac47-ab3d02cc2eb4.png) | Featured content | | 1. union()The new Set union() method gives us all the unique items in both sets. | ![](https://mcusercontent.com/42d7a8f52e460525417e7989f/images/30a5cc17-7c9a-806a-8473-e398fea6ea3d.png) | And since it's immutable and returns a copy, you can chain it indefinitely: | ![](https://mcusercontent.com/42d7a8f52e460525417e7989f/images/157c6782-ab53-0ed7-ffcc-386a449cb5b9.png) | 2. intersection()What elements are in both sets? | ![](https://mcusercontent.com/42d7a8f52e460525417e7989f/images/2aa10374-d260-0c7d-11c3-c5d88de73e62.png) | | | JavaScript Mutation Observer.
An underrated API for watching for changes in the DOM: "child added", "attribute changed", and more. | ![](https://mcusercontent.com/42d7a8f52e460525417e7989f/images/1651540c-a891-471e-e9a8-7464762ed4c1.png) | I see a bunch of people online curious to know the point of this API in the real-world.
In this post I'll show you how I used it to easily shut-up this annoying script carrying out unwanted activities on the page.
And you'll see how sleek and polished the UI elements became after this. | | | Of course <br/> is what we all grew up with from our HTML beginnings, but there's more.
Like... CSS white-space: pre-wrap: | ![](https://mcusercontent.com/42d7a8f52e460525417e7989f/images/fd402955-6db3-5429-c190-8b2a0755a81c.png) | ![](https://mcusercontent.com/42d7a8f52e460525417e7989f/images/27a7f008-5295-b11d-ef31-098008b72d08.png) | ![](https://mcusercontent.com/42d7a8f52e460525417e7989f/images/c90b5da8-a92b-572d-aea2-3377497714f0.png) | | | On Twitter/X | ![](https://mcusercontent.com/42d7a8f52e460525417e7989f/images/8166220e-fb08-016d-bbb0-15c958bbfafc.png) | | | | | | |
|
|
|
| |
0 Komentar untuk "7 new Set methods in JavaScript: union(), intersection(), +5 more"