Search code examples
javascriptclassecmascript-6browser-support

How to test if browser supports js ES6 Class?


My js classes works fine in Chrome, but when I test in IE for example, the script fails as expected, giving an ugly syntax error.
Is there someway to test if the clients browser can handle ES6 Classes in javascript?


Solution

  • Technically you could

    try { eval('"use strict"; class foo {}'); } catch (e) { console.log(e); }
    

    practically I don't see it's reasonable to prefer it to transpiling at least these days.