PDA

View Full Version : "batch-assign" attributes between objects?


bryndyment
03-28-2003, 08:11 PM
Easily-described question...

Can you "batch-assign" attributes between objects? Or is there only this brute-force way:

objOne.a = objTwo.a
objOne.b = objTwo.b
objOne.c = objTwo.c
etc.

I know you can loop through an object's attributes, but can't find any way to specify an attribute via anything other than typing out its name.

Just checking...

brothercake
03-28-2003, 08:14 PM
I may be wrong here, but since

obj.a

can also be expressed as

obj['a']

then presumably you could iterate through a collection of objects with a variable name in place of the property name.

bryndyment
03-28-2003, 08:23 PM
Yes! Thanks for making my Friday even happier...