JSFiddle - React, Tailwind, and code Playground

JavaScript

function getBrowser(ua, platform) {
    ua = ua.toLowerCase();
    platform = (platform ? platform.toLowerCase() : '');

    // chrome is included in the edge UA, so need to check for edge first,
    // before checking if it's chrome.
    var UA = ua.match(/(edge)[\s\/:]([\w\d\.]+)/);
    if (!UA) {
        UA = ua.match(/(opera|ie|firefox|chrome|trident|crios|version)[\s\/:]([\w\d\.]+)?.*?(safari|(?:rv[\s\/:]|version[\s\/:])([\w\d\.]+)|$)/) || [null, 'unknown', 0];
    }

    if (UA[1] == 'trident') {
        UA[1] = 'ie';
        if (UA[4]) UA[2] = UA[4];
    } else if (UA[1] == 'crios') {
        UA[1] = 'chrome';
    }

    platform = ua.indexOf('windows phone') != -1 ? 'windowsmobile' : ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || ua.match(/mac|win|linux/) || ['other'])[0];
    if (platform == 'win') platform = 'windows';

    return {
        //extend: Function.prototype.extend,
        name: (UA[1] == 'version') ? UA[3] : UA[1],
        version: parseFloat((UA[1] == 'opera' && UA[4]) ? UA[4] : UA[2]),
        platform: platform
    };
};
var browser = getBrowser(navigator.userAgent, navigator.platform);
alert(JSON.stringify(browser, null, 4));