function getIEVersion(userAgent) {
  // IE11 may identify itself as MSIE 9.0 or MSIE 10.0 due to an IE 11 upgrade
  // bug. Example UA:
  // Mozilla/5.0 (MSIE 9.0; Windows NT 6.1; WOW64; Trident/7.0; rv:11.0)
  // like Gecko.
  const rv = /rv: *([\d\.]*)/.exec(userAgent);
  if (rv && rv[1]) {
    return Number(rv[1]);
  }

  const msie = /MSIE +([\d\.]+)/.exec(userAgent);
  if (msie && msie[1]) {
    // IE in compatibility mode usually identifies itself as MSIE 7.0; in this
    // case, use the Trident version to determine the version of IE. For more
    // details, see the links above.
    const tridentVersion = /Trident\/(\d.\d)/.exec(userAgent);
    if (msie[1] == '7.0') {
      if (tridentVersion && tridentVersion[1]) {
        switch (tridentVersion[1]) {
          case '4.0':
            return 8;
          case '5.0':
            return 9;
          case '6.0':
            return 10;
          case '7.0':
            return 11;
        }
      } else {
        return 7;
      }
    } else {
      return Number(msie[1]);
    }
  }
  return NOT_IE;
}
Get corrected IE version, see goog.labs.userAgent.browser.getIEVersion_
@param {string} userAgent the User-Agent.
@return {number}