<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>javascript026.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<script type="text/javascript">
//面向对象中,最核心的概念就是类。
//类表示具有相似性质的一类事物的抽象。
//通过实例化一个类,就能够得到一个类的对象。
//我们如何自己定义对象呢?通过刚才的讲解,我们想到了使用function模拟。
/*
在java中,定义类格式如下:
class 类名
{
}
*/
//定义一个类:定义了一个Person类。
function Person()
{
}
//问题来了,类定义好了,怎么用啊。
//回想:new Date(),new String()
//new操作符不仅仅对js的内置对象有效,对用户自定义的类也是同样有效的。
//也就是说,你完全可以使用new关键字来创建自定义类的对象。
var p = new Person();
//alert(typeof p); //object
//alert(typeof Person); //function
//这个对象没有任何属性的和功能。
//其实也就是这个类没有。怎么办呢?如何给对象添加属性和功能呢?
</script>
</body>
</html>