关于原型和继承的问题。
刚开始学javascript,遇到了一个问题。
指定了对象的prototype属性后,没有效果,就像没有制定一样。
代码如下,望达人解疑。
sd.htm:
<script type="text/javascript" src="aa.js">
</script>
<input type="button" onClick="alert(bb.getYear());" value="jjjj">
aa.js:
function nn()
{
var jj={
name: "malpower",
age: 15,
prototype: new Date(),
school: "天堂",
show: function(){window.alert("I am "+this.name+","+this.age+" 岁,就读于 "+this.school+" "+this.prototype.getYear());}
};
return jj;
}
var bb=new nn();