I am extremely new to JavaScript so please bear with me on this one. Here is a snippet of my code:
function Course(title, instructor, views){
this.title= title;
this.instructor = instructor;
this.views = views;
this.updateViews = function() {
return ++this.views;
};
}
var course1 = new Course('JS', 'Sarun', 0);
console.log(course1.updateViews);
On execution however, I had expected the value of course1.updateViews to be 1. Instead, I get the entire function displayed in the console as follows:
ƒ () {
return ++this.views;
}
I am sure that this is a beginner's mistake. So can anyone please Correct me on this?