Why is Firefox giving a syntax error, class is a reserved identifier?

Opening a file called index.html with the following code in Firefox 43 produces the following error:

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script> "use strict"; class RangeIterator {} </script> </head> <body> </body> </html> 

I see the following error in the console:

 SyntaxError: class is a reserved identifier 

Any idea why I am getting this error?

+6
source share
2 answers

Classes are not supported in Firefox version <45 according to this

+19
source

According to Can I Use ES6, classes support form 45 of the version of Firefox. if version 45 also throws the same error as SyntaxError: class is a reserved identifier , then it is better to convert it to ES5.

enter image description here


Babel is a JavaScript compiler. Use it to convert ES6 to ES5 BABEL JS (or) ES6Console .

ES2015 classes "Check below Converted from ES6 to ES5 .

 // ES6 ES5 class Shape { "use strict"; constructor(color) { this._color = color; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } } } var Shape = function Shape(color) { _classCallCheck(this, Shape); this._color = color; }; 

@see

0
source

All Articles