面向对象的基础
1.声明一个对象
var myperson={
name : "Zhang",
age : 25,
sex : "male",
introduction:function(){
alert(name+age+sex);
}
};
myperson.introduction();
2.使用构造函数构造
构造函数与普通函数的区别在于调用方式,构造函数使用new方法构造。
function creatrPerson(name,age,sex,interests){
this.name = name;
this.age = age;
this.sex = sex;
this.interests = interests;
this.bio = function(){
var res = "";
if(this.sex == "male"){
res+="He ";
}else if(this.se