<script type="text/javascript"> function show() { window.alert(this.info); }
function MyInformation(mycity,myuniversity,myyear) { this.city=mycity; this.university=myuniversity; this.year=myyear; this.info="毕业于"+this.city+this.university+":"+this.year+"年"; this.show=show; }
MI=new MyInformation("成都","电子科技大学","1999"); </script> <form> <input type="button" value="aboutme" /> </form>
这是一般js教材上的一段例子 但讲解得不是很详细
我想问问的是 1.在前面的function show()中的"this"不是指show()吗? 但好像实际情况是指MyInformation() 为什么会这样?? 2.function MyInformation中的"this.show=show;"到底有什么用啊? 删除又不能运行.
如有表述错误不要见怪~初学者~ 越详细越好~~~~~谢谢~
|