How to run ES6 code with arrow functions in Safari?

nonopolarity picture nonopolarity · Jan 29, 2016 · Viewed 8k times · Source

For some reason, ES6 code that runs well in the current Chrome or Firefox cannot run in Safari - for example, arrow functions. As I know, Safari has ok support for ES6. Is there something that needs to be done?

Example:

var arr = [1,3,5].map((i) => i*i);
console.log(arr);

Or if it is a full .html file:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>

        <script>
            "use strict";

            var arr = [1,3,5].map((i) => i*i);
            console.log(arr);

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

Safari (I am using 9.0.3) keeps on giving SyntaxError: Unexpected token '>'

Answer

Krease picture Krease · Jan 29, 2016

Based on the MDN link, (near the bottom), Safari does not yet support this feature.