<script>
function TA()
{
this.FName = "TA";
}function CopyObject(oA, oB)
{
for(var i in oA){
oB[i] = oA[i];
}
}function Demo()
{
var a = new TA();
var b = new Object();
CopyObject(a, b);
a.FName = "X";
alert(b.FName); // 此时显示的还是"TA"
}
</script>
<button onclick=Demo()>Demo</button>
function TA()
{
this.FName = "TA";
}function CopyObject(oA, oB)
{
for(var i in oA){
oB[i] = oA[i];
}
}function Demo()
{
var a = new TA();
var b = new Object();
CopyObject(a, b);
a.FName = "X";
alert(b.FName); // 此时显示的还是"TA"
}
</script>
<button onclick=Demo()>Demo</button>
<!--
a=new Array
a.name='llrock'
function clone(e){
var newObj=new Array;
for(var count in e){
newObj[count]=e[count]
}
return newObj;
}
b=clone(a)
a.name='百乐宝'
alert(b.name)
//-->
</SCRIPT>
如果你想创建浏览器元素的副本可以使用cloneNode