Rara’s student card on the teacher’s board: your data-* attributes read and written through a real el.dataset. What comes back for a kebab-case name, for a…
data-* is used for event delegation (a data-id on every row), state-based styling ([data-state="open"]) and component config. Reading the wrong name (kebab vs camel) or forgetting to convert the type is a subtle, common bug.
Names turn camelCase, values are always strings
dataset['user-id'] and getting undefined JS uses camelCase: the data- prefix goes and every -letter becomes a capital. Use dataset.userId, not the kebab-case form.if (dataset.isActive) is always true even when it says "false" Every dataset value comes out as a string, and a non-empty string is truthy. Compare explicitly: dataset.isActive === 'true', or Number(dataset.x) for numbers.data-json It shows in the HTML, is downloaded with it, and must be JSON.parsed on every read (an error when the format slips). For big or structured data, keep it in JS state and put only its id in data-*.['user-id'] It is undefined: the JS key is userId. See the table on the board..lastLogin = '2026-10-16' A data-last-login attribute appears in the HTML: camelCase turned back into kebab-case.['last-login'] = 'x' The browser refuses with SyntaxError: a dataset key may not hold - followed by a lowercase letter.data-is-active to "false" in the HTML With if (el.dataset.isActive) the ACTIVE badge still shows: the string "false" is truthy.