How to replace a class of element in JavaScript

DOM
Last updated Mar 11, 2018
<div id="box"></div>
const element = document.querySelector("#box");

element.classList.replace("old-class-name", "new-class-name");