篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript JS OOP 101 for WCS相关的知识,希望对你有一定的参考价值。
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
tellMyName (){
return `I am ${this.name}`
}
tellMyAge() {
return `I am ${this.age}`
}
}
let person1 = new Person('John', 40)
let person2 = new Person('Mary', 35)
console.log(`${person1.tellMyName()} and ${person1.tellMyAge()}`)
console.log(`${person2.tellMyName()} and ${person2.tellMyAge()}`)
以上是关于javascript JS OOP 101 for WCS的主要内容,如果未能解决你的问题,请参考以下文章