The purpose of using the spread syntax in this scenario is to transform the NodeList obtained from the `querySelectorAll` method into an array, allowing us to utilize the `map` function. Since NodeList does not natively support `map`, only `forEach`, we need to perform this conversion.
The `dataset` property encompasses all the `data-*` attributes, with the specific focus here being on retrieving the value of `data-filter`. The code snippet below demonstrates this concept:
const filters = [...document.querySelectorAll('.btn.active')]
.map((el) => el.dataset.filter);
console.log(filters); // ["foo", "bar", "baz"]
<div class="btn active" data-filter="foo"></div>
<div class="btn active" data-filter="bar"></div>
<div class="btn active" data-filter="baz"></div>