ES6 classes do not work on Chrome 47

Google Chrome claims to support ES6 classes from version 42, but gives Uncaught SyntaxError: Unexpected token class(โ€ฆ) when I run simple code from below in the console:

 class Polygon { constructor(height, width) { this.name = 'Polygon'; this.height = height; this.width = width; } 

Firefox also does not work. Microsoft Edge works great. This is normal?

+6
source share
1 answer

Are you in strict mode?

ES6 classes solve this by providing JavaScript with clean, standardized class syntax. This new syntax is available in Chrome 42 for strict mode JavaScript.

+7
source

All Articles