<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>JS对象</title>
<script language="javascript">
function print(){
document.write("书名为:" + this.name + "<br>");
document.write("作者为:" + this.author + "<br>");
}
function book(name,author){
this.name = name;
this.author = author;
this.print = print; //没有括号
}
</script>
</head>
<body>
<script language="javascript">
var c = new book("C语言","谭浩强");
c.print();
document.write("<br>");
for(var prop in c){
document.write(prop + ":" + c[prop] + "<br>");
}
document.write("<br>");
book.prototype.price = 10;
for(var prop in c){
document.write(prop + ":" + c[prop] + "<br>");
}
</script>
</body>
</html>