Make Javascript ES6 cross-browser detection by using new syntax () => {}; - Javascript Language Basics

Javascript examples for Language Basics:Javascript Version

Description

Make Javascript ES6 cross-browser detection by using new syntax () => {};

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>isES6()</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){// w w w. j  a v a 2 s  . co m
function isES6()
{
    try
    {
        Function("() => {};"); return true;
    }
    catch(exception)
    {
        return false;
    }
}
document.body.innerHTML += "isES6: " + isES6();
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials