I found this code in a book:
class Animal(){
constructor(){
this.legs = 4;
this.eyes = 2;
this.say = "Huh?"
}
speak(){
console.log(this.say)
}
}
The above should be the correct way to define a class, but I cannot use it in FF or chrome. I gotSyntaxError: class is a reserved identifier
I also played with modules. I put
export let hello = "hello from the first module" in firstModule.js file
than i put
import {hello} from "firstModule"
console.log(hello)
in the main.js file
and I put <script type="text/javascript" src="main.js"></script>in the index file and I gotSyntaxError: modules are not implemented yet
I assume that I have problems with es6 syntax that I thought I could, especially if I use babeljs
I hope you could see in this "try" link the link I tried to use the class operator, but I got an error Unexpected token (1:15).
How to use es6 material? I thought Babel should have switched es6 to es5. what am I doing wrong?
I also put <script type="application/javascript;version=1.7">in html file