making one object a parent of another via javascript

I'm trying to make the camera move with another object as it moves around the screen. The target object is rotating, and the code I am using below makes the camera rotate with the object.. how can I keep it so it just moves with the object and doesn't rotate.

One option is to put the object in a container and make the camera the child of the container (and a sibling of the object) and have the container control movement and rotation of the object, so long as the container doesn't rotate, the camera wont either.

Option 2 is to use a smooth follow script or similar to make the camera track the position of the object without using parenting. You can do this with vector3 lerp and a minimum distance parameter to have the camera follow the object from a certain distance

You can also drag the Camera onto the Gameobject in Sceneview, and it is parented. But this will not work with Prefabs without breaking the link, therefor do "Option One" from spinaljacks answer