Comment by nine_k
The point of this exercise, to my mind, is to show the utter simplicity of pub-sub. Such code belongs to the API documentation, like the code snippets on MDN.
Proper code would have expressive parameter names, good doc comments, types (TS FTW) and the niceties like unpacking you mention. One of them would be named topics mapped to EventTargets, so that publishers and subscribers won't need to have visibility into this implementation detail.