Using `.dataset` is my go-to for javascript get data attribute! It’s clean and easy to read.
Like: `element.dataset.someValue` instead of `getAttribute('data-some-value')`.
Only downside? It doesn’t work in super old browsers, but who cares about IE these days? 😅
For performance, `.dataset` is slightly slower than `getAttribute()`, but unless you’re doing thousands of ops, it won’t matter.
Like: `element.dataset.someValue` instead of `getAttribute('data-some-value')`.
Only downside? It doesn’t work in super old browsers, but who cares about IE these days? 😅
For performance, `.dataset` is slightly slower than `getAttribute()`, but unless you’re doing thousands of ops, it won’t matter.
