原型对象

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html";charset="gbk"/ >
<script type="text/javascript" >
 function Person(name,age){
    this.name = name;
    this.age = age;
    this.show = function(){
      alert(this.name+":"+this.age);
    }
 }
 var s =  new Person("ww",32);
 var d = new Person("ranran",24);
 
 s.show();                                        ww:32


 alert(s.constructor==Person);          true           constructor 属性返回对创建此对象的数组函数的引用。


 alert(s instanceof Person);                true          java 中的 instanceof 运算符是用来在运行时指出对象是否是特定类的一个实例。

                                                                      instanceof通过返回一个布尔值来指出,这个对象是否是这个特定类或者是它的子类的一个实例。
</script>
</head>
<body>
   
</body>
</html>

posted @ 2014-02-20 16:00  birdlow  阅读(97)  评论(0)    收藏  举报