Store initial rotation in JavaScript

So what I’m trying to figure out, and could not decipher from other answers found here, is exactly how to store the rotation of my ship so that I may use it to reset to zero later on in the script. I thought I was doing it correctly, but obviously I’m missing something very important here. Could someone please help me out and explain what I’m doing wrong? Again, this is Javascript.

var originalRotationZ = Quaternion;

 function Start ()
 {
  transform.rotation.eulerAngles.z = originalRotationZ; // store rotation on start
 }

This is wrong:

var originalRotationZ = Quaternion;

Quaternion is a type, not a value that you can assign to variables. It’s unclear if you’re trying to store the entire rotation or just the Z axis. So it’s either:

var originalRotationZ : float;

function Start () {
    originalRotationZ = transform.eulerAngles.z;
}

or

var originalRotation : Quaternion;

function Start () {
    originalRotation = transform.rotation;
}

You are trying to store a Quaternion in eulerAngles you can instead; store the eulerAngles in a Vector3 and then set them as shown in the first link. Or you can do this:

transform.rotation.eulerAngles.z = originalRotationZ.eulerAngles.z;

which according to Transform-eulerAngles

Do not set one of the eulerAngles axis
separately (eg. eulerAngles.x = 10; )
since this will lead to drift and
undesired rotations.