I have two javascript maps:
var map1 = { x : y }; var map2 = { a : b };
I want to copy both maps into one single map. Does anybody have an idea how I can achieve this?
Object properties in JavaScript can be treated just like arrays:
<script type="text/javascript"> onload=function(){ var map1 = { x : 1 }; var map2 = { a : 2 }; var newMap = new Object(); copyProp(newMap, map1); copyProp(newMap, map2);
function copyProp(dest,src){ for (var i in src) dest[i] = src[i]; };
function dumpProp(obj){ var str =""; for (var i in obj) str += obj[i]+" "; return str; };
alert(dumpProp(newMap)); } </script>
Hope this helps Steve
_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]