Gags
Gags

Reputation: 903

Safari browser reports error using classes in javascript

I use a class in my javascript.

 class FileSet {
        constructor(id,
                    path,
                    folder,
                    children,
                    all,
                    isfolder
            ) {
        }
    }

It works in all browsers except Safari. In Safari I get the following exception. SyntaxError: Use of reserved word 'class'

How do I make my script run in Safari browser.

Thanks, Gagan

Upvotes: 1

Views: 782

Answers (1)

Ankit Agarwal
Ankit Agarwal

Reputation: 30739

You might be using safari browser less that version 9. The class keyword is a reserved keywork in ES6 and safari browser do not support ES6 less than version 9. So, you must need to update your browser to version 9 or more to get your JavaScript work.

Upvotes: 2

Related Questions