level 14
CRI刘小八
楼主
<script>
function Person(){
this.name = "lc";
this.age =27;
this.color = "red";
};
Person.prototype.run = function(){
alert (this.name);
}
var o = new Person();
alert(o.run());
</script>
将属性定义在函数里,将属性值为方法的属性利用prototype在函数之外定义,这时运行
时会alert出两个值,一个是"lc",一个是undefined,后面的那个undefined是怎么出来的
呢?
2015年12月31日 01点12分
1
function Person(){
this.name = "lc";
this.age =27;
this.color = "red";
};
Person.prototype.run = function(){
alert (this.name);
}
var o = new Person();
alert(o.run());
</script>
将属性定义在函数里,将属性值为方法的属性利用prototype在函数之外定义,这时运行
时会alert出两个值,一个是"lc",一个是undefined,后面的那个undefined是怎么出来的
呢?