Image object replacement in Javascript

I just did document.images[1]=myImageObject and it worked. I only tried it as a last resort as I thought it would be silly and the console would moan at me. Sometimes I hate Javascript; sometimes it’s lovely.