Here's the code:
Code:
// generates a nice bright yellow to oranges palette
function genPalette()
{
	var icols = 0;
	var color = new Object();
	color.r = 0;
	color.g = 0;
	color.b = 0;
	// Make 154 color palette starting with black
	palette[icols] = color;
	icols++;
	for( ; color.r < 255; color.r += 5) {
		palette[icols] = color;
		alert("Here" + palette[0].r);
		icols++;
		color.g = Math.floor(color.r / 2); //Make and orange
		palette[icols] = color;
		icols++;
		color.b = Math.floor(color.r / 4); //Make a yellow
		icols++;
	}
	return icols;
}

var palette = new Array(155);
genPalette();
When the following code is run palette[0].r continues to change to whatever palette[icols].r is. It's as if the whole array changes whenever one element is changed. I'm new to javascript, but I've used C++ a lot. So what's going on here?