批改状态:合格
老师批语:作业下次写上标题
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
</head>
<script type="text/javascript" charset="utf-8">
// 构造函数创建对象
var Obj = function(){
this.name = 'lili';
this.age = 18;
this.func = function(){
return document.write('my name is' + this.name + 'my age is' + this.age );
};
};
var obj1 = new Obj();
obj1.func();
// prototype函数添加对象成员
Obj.prototype.sex = 'boy';
document.write('</br>')
document.write(obj1.sex);
</script>
<body>
</body>
</html>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号