I know this refers to the constructor method but what does the line this.tasks = tasks; do?
class TaskCollection {
    constructor(tasks =[]) {
        this.tasks = tasks;
    }
}
I know this refers to the constructor method but what does the line this.tasks = tasks; do?
class TaskCollection {
    constructor(tasks =[]) {
        this.tasks = tasks;
    }
}
 
    
     
    
    That line assigns the tasks passed in through the constructor to the "tasks" member of the class instance.
Basically, you can do this:
collection = new TaskCollection([task1,task2]);
Now, you can access those tasks like this:
collection.tasks // [task1,task2]
 
    
    I don't think there is the reserved word Class in javascript, function TaskCollection here defines the class, this code works fine in a jsfiddle but needs to define what is the array tasks, and also define what is the constructor reserved word
function TaskCollection (name, tasks) {
        this.name = name;
        this.tasks = tasks;
}
var collection = new TaskCollection('col', ['task1','task2']);
console.log(collection.name);
