JavaScript Classes review
Some basic notes
// *****START CLASS***********************************************
//The constructor function is called automatically when an instance of the class is created.
// a special method for creating and initializing an object created with a class.
// There can only be one special method with the name “constructor” in a class.
class Person {
constructor (name,age) { //this is a function
// console.log(name,age)
this.name=name;
this.age=age;
}
//methods
getUserDescription(){return `${this.name} is ${this.age} year(s) old`}
}
// *****END CLASS***********************************************
var me = new Person(“Andrew”,25); //arguments are passed to constructor function
// console.log(“this.name”, me.name)
// console.log(“this.age”, me.age)
var description = me.getUserDescription(); // Andrew is 25 year(s) old
console.log(description);