示例参考
function User(name, age, gender) {
this.name = name;
this.age = age;
this.gender = gender;
}
function Dog() {
this.age = 5;
this.gender = 'male';
this.叫 = function () {
console.log('Muhahaha!');
}
}
var whh = new User('王花花', 18, 'male');
console.log('whh:', whh);
var dog = new Dog();
dog.叫();
console.log('dog:', dog);
function Book() {
this.title = 'LALALA';
this.author = 'Muhaha';
}
var book = new Book();
console.log(book);
登录后评论