How to get data attribute from element in JavaScript

DOM
By Jad Joubran · 
Last updated Jul 28, 2018
<div id="box" data-user-id="123"></div>
const box = document.querySelector("#box");
const userId = box.dataset.userId;
123
dataset on MDN