<script type="text/javascript">
function Person(){
this.name="???";
this.sayHellow= function(){
alert("Hi, I am " + this.name);
return 1;
}
}
var parentPerson = new Person();
function Student(){
this.name="Ben";
this.age="28";
}
Student.prototype = new Person();//new Person()是一个对象
new Person().sayHellow();
new Student().sayHellow();
var t = new Student().sayHellow();
alert("t's value:"+t);
alert(Object.length);
alert("typeof new Person():::::::"+typeof new Person());//Object
alert("Person::::"+Person);//输出Person定义的全部内容
alert("typeof Person:::::"+typeof Person);//function
var XXX = function(){alert("xxx");}
new XXX();
alert("new XXX():"+new XXX());
alert("new XXX()::::"+new XXX());//xxx
alert("new XXX().constructor:::::"+new XXX().constructor);//function(){alert("xxx");}
function Person(){
this.name="???";
this.sayHellow= function(){
alert("Hi, I am " + this.name);
return 1;
}
}
var parentPerson = new Person();
function Student(){
this.name="Ben";
this.age="28";
}
Student.prototype = new Person();//new Person()是一个对象
new Person().sayHellow();
new Student().sayHellow();
var t = new Student().sayHellow();
alert("t's value:"+t);
alert(Object.length);
alert("typeof new Person():::::::"+typeof new Person());//Object
alert("Person::::"+Person);//输出Person定义的全部内容
alert("typeof Person:::::"+typeof Person);//function
var XXX = function(){alert("xxx");}
new XXX();
alert("new XXX():"+new XXX());
alert("new XXX()::::"+new XXX());//xxx
alert("new XXX().constructor:::::"+new XXX().constructor);//function(){alert("xxx");}
alert(new XXX().constructor);
alert(typeof Student.prototype);// OBJECT由此可见prototype也是一个对象