也可在外部添加属性
<script>
function myObj(){}
myObj.prototype.p1=0
function myObj.prototype.show(){
for(ob in this)alert(ob+"="+this[ob]);
}
var myObj1 = new myObj()
myObj1.p1="value";
myObj1.show()
</script>
<script>
function myObj(){
this.p1=0;
this.show=showProp
}
function showProp(){
for(ob in this)alert(ob+"="+this[ob]);
}
var myObj1 = new myObj()
myObj1.p1="value";
myObj1.show()
</script>