Open swati-jagtap opened 3 years ago
class Animal{ constructor(name,age,color,legs){ this.name=name; this.age=age; this.color=color; this.legs=legs; console.log(this) //1 } get getinfo(){ return `${this.name.toUpperCase()} is my pet.${this.name} is ${this.age} yers old.`; } setName(){ this.owner="johny"; // let Name=this.name.toUpperCase(); return `${this.owner} was his owner`; // return `${Name}`; } birthYear(){ const d=new Date(); const Birth=d.getFullYear()-this.age; return `${this.name}'s Year Of Birth is : ${Birth}`; } } const A1=new Animal("tyson",2,"brown",4); console.log(A1.getinfo); console.log(A1.setName()); console.log(A1.birthYear()); console.log(A1); //2 console.log(Animal) //3 console.log(A1.name); //4