<script language="JavaScript">
function MYOBJ(name,age,sex) {
this.name = name;
this.age = age;
this.sex = sex;
this.toString = function(){
return "姓名:"+ this.name +"年龄:"+ this.age +"性别:" + this.sex
};
}
//在程序中便可以直接使用该对象,及其对象的属性和方法
var obj = new MYOBJ("ballack",26,"male");
alert(obj.toString());
alert(typeof(obj));
alert(obj instanceof MYOBJ);
alert(obj.constructor == MYOBJ);
</script>