Your cart is currently empty!
js面向对象
简单的面向对象:
<script>
function Person() {
this.realname="Person RealName";
}
function User(username,birthday,gender) {
Person.apply(this,arguments);
this.username=username;
this.birthday=birthday;
this.gender=gender;
}
User.prototype.getUsername=function () {
return "name is :"+this.username;
};
function h() {
User.prototype=new Person();
let justmyvar=new User("小明",1573525293,1);
let anothervar=new User("小红",1573525093,0);
justmyvar.realname="张啸明";
console.log(justmyvar.realname);
console.log(anothervar.realname);
}
</script>
标签:
发表回复