Q:

HTML5 data attributes casting null and undefined to string

Consider the example code bellow from an HTML file:
 <div id="book"
     data-id="47909"
     data-title="Under The Dome" 
     data-author="Stephen King"
     data-year="2009">
 </div>

Selecting the book element with:
book = document.querySelector("#book");

Whenever I set some attribute to null or undefined it sets it to a string "null", "undefined" respectively:
book.dataset.author = null
typeof book.dataset.author
"string"

book.dataset.year = undefined
typeof book.dataset.year
"string"

While
let a = null;
typeof a
"object"

let b = undefined;
typeof b
"undefined"

Can someone please explain me why it behaves like this? Does it has to do with the fact that in the end everything will be converted to a string due to the nature of it being an element attribute?
Thanks!

A:

As per spec of dataset

On getting, the dataset IDL attribute must return a DOMStringMap whose
  associated element is this element.

and as per spec of DOMString's value

Attributes have a namespace (null or a non-empty string), namespace
  prefix (null or a non-empty string), local name (a non-empty string),
  value (a string), and element (null or an element).

hence the value is casted to String before returning
String(null); //"null"
String(undefined); //"undefined"
String(1); //"1"

