-1
Hello! I am new using ES6, I did the installation of Babel, so when using array the Bundle accuses BABEL_PARSE_ERROR. It appears like this: Syntaxerror: C: xampp htdocs ES6 main.js: Unexpected token (3:20)
The code I’m using is as follows::
class todoList{
constructor(){
this.todos[];
}
addTodo(){
this.todos.push("Novo todo");
console.log(this.todos);
}
}
const MinhaLista = new todoList();
document.getElementById('novotodo').onclick = function(){
MinhaLista.addTodo();
}
The error is precisely in the array inside the constructor: constructor(){ this all.[]; }
Can anyone tell me if there are any updates that have modified this, or if I’m doing something wrong?
Really, I was missing the equal sign between everyone and []. Thank you! Lack of attention my xD
– David Magalhães