Hey! For grabbing data attributes in JS, I always use `getAttribute()` because it’s straightforward.
Like:
```js
const val = el.getAttribute('data-thingy');
```
But `dataset` is cool too—just depends on your style.
Btw, if your get data attribute javascript code fails, check if the element exists first. Common mistake!
Like:
```js
const val = el.getAttribute('data-thingy');
```
But `dataset` is cool too—just depends on your style.
Btw, if your get data attribute javascript code fails, check if the element exists first. Common mistake!
