<!DOCTYPE HTML><html><head><title>please enter your title</title><metacharset="utf-8"><metaname="Author"content="潭州学院-阿飞老师"><styletype='text/css'>
*{ margin:0; padding:0;}</style></head><body><scripttype="text/javascript">/*
new : 只能用来创建对象
函数在调用的时候,前面加上new的话:
这个函数里面的this就是调用后创建的对象;
默认返回对象
*///构造函数 (构造函数名第一个字母大写 潜规则)functionPerson( name ){this.name = name;
this.showName = function(){
alert( this.name );
}
}
var obj1 = new Person('Eva');
var obj2 = new Person('三十二度大富油');
var obj3 = new Person('发型不乱');
var obj4 = new Person('年轻人');
alert( obj1.showName == obj2.showName )
//obj1.showName();</script></body></html>