вот работающий полностью код
const use = {
test: regexp => regexp.test(window.navigator.userAgent),
get browser() {
switch (true) {
case this.test(/edge/i):
return 'edge'
case this.test(/edg/i):
return 'chromium based edge (dev or canary)'
case this.test(/opr/i) && !!window.opr:
return 'opera'
case this.test(/chrome/i) && !!
window.chrome:
return 'chrome'
case this.test(/trident/i):
return 'ie'
case this.test(/firefox/i):
return 'firefox'
case this.test(/safari/i):
return 'safari'
default:
return 'other'
}
}
}
console.log(use.browser)