Javascript Constructor + create objects example
//Constructor
function Course(title,instructor,level,published,views){
this.title = title;
this.instructor = instructor;
this.level = level;
this.published = published;
this.views = views;
this.updateViews = function() {
return ++this.views;
}
}
//Create Objects
var a = new Course("A title", "A instructor", 1, true, 0);
var b = new Course("B title", "B instructor", 1, true, 123456);
//Log out objects properties and methods
console.log(a.title); // "A Title"
console.log(b.updateViews()); // "123457"
what is the python equivalent of this? (Constructor function / or class + create object instances + log out properties & methods?)
Is there a difference between self from python and this from Javascript?