xml
<script>
/*
es5类写法
function Persion(name, age) {
this.name = name,
this.age = age
}
Persion.prototype.say = function() {
console.log(this.name + "say");
}
let p = new Persion("贾维斯", 30)
p.say()*/
class Pesion {
constructor(name, age, sex) {
this.name = name
this.age = age
this.sex = sex
}
say() {
console.log(this.name + "say");
}
get sexer() {
return this.sex
}
set sexer(s) {
this.sex= s
}
}
let p = new Pesion("贾维斯", 30)
p.say()
p.sexer = "贾维斯1"
console.log(p.sexer);
</script>