How to get extension from input type file in JavaScript

Functions
Last updated Nov 05, 2018
<input type="file" id="upload">
const upload = document.querySelector("#upload");

upload.addEventListener("change", event => {
  const file = event.currentTarget.value;
  if (!file) {
    return false;
  }
  const extension = file.substr(file.lastIndexOf(".") + 1);
});