getIEVersion = function(agent) {
  // https://stackoverflow.com/questions/19999388/check-if-user-is-using-ie
  if (typeof agent === 'undefined') {
    agent = window.navigator.userAgent;
  }

  let pos = agent.indexOf('MSIE '); // up to IE10
  if (pos > 0) {
    return parseInt(agent.substring(pos + 5, agent.indexOf('.', pos)), 10)
  }

  pos = agent.indexOf('Trident/'); // IE11
  if (pos > 0) {
    pos = agent.indexOf('rv:');
    return parseInt(agent.substring(pos + 3, agent.indexOf('.', pos)), 10)
  }

  return false
}
Returns Internet Explorer version number (or false if no Internet Explorer used).

@param string agent Optional parameter to specify user agent