converting c# to javascript error

:!:
unknown error happened when i tried convert c# code to javascript code, the code is to make “Instant Replay” by record an object positions then replay it again, in c# code worked well, but when i convert it to javascript it gave me error, the following are codes and console error report, I hope someone guide me where is my wrong in javascript code:

c# code:

using UnityEngine;
using System.Collections.Generic;

public sealed class Recorder : MonoBehaviour
{
  private bool isRecording = false;
  private bool isReplaying = false;
  private int currentFrame = 0;
  private List<Vector3> snapShots = new List<Vector3>();

  private void FixedUpdate()
  {
    if (isRecording)
    {
      gameObject.name = "Recorder (Recording)";
      snapShots.Add(transform.position);
    }
    else if (isReplaying)
    {
      gameObject.name = "Recorder (Replaying)";
      transform.position = snapShots[currentFrame];
      ++currentFrame;
      if (currentFrame >= snapShots.Count)
      {
         isReplaying = false;
      }
    }
    else
    {
      gameObject.name = "Recorder (Idle)";
    }

    // Toggle recording
    if (Input.GetKeyDown("1"))
    {
       isRecording = !isRecording;
       isReplaying = false;
       if (isRecording)
       {
          // Create new snapShots for new recording
          snapShots = new List<Vector3>();
       }
    }

    // Toggle playback
    if (Input.GetKeyDown("2"))
    {
       isRecording = false;
       isReplaying = !isReplaying;

       if (isReplaying)
       {
          // Reset currentFrame
          currentFrame = 0;
       }
    }
  }
}

javascript code:

private var isRecording : boolean = false;
private var isReplaying : boolean = false;
private var currentFrame : int = 0;
private var snapShots = new Array (Vector3);

function FixedUpdate()
{
if (isRecording)
    {
      gameObject.name = "Recorder (Recording)";
      snapShots.Add(transform.position);
    }
else if (isReplaying)
    {
      gameObject.name = "Recorder (Replaying)";
      //transform.position = snapShots[currentFrame];
	  transform.position = snapShots[currentFrame];
      currentFrame++;
      if (currentFrame >= snapShots.length)
      {
         isReplaying = false;
      }
    }
	    else
    {
      gameObject.name = "Recorder (Idle)";
    }


    // Toggle recording
    if (Input.GetKeyDown("1"))
    {
       isRecording = !isRecording;
       isReplaying = false;
       if (isRecording)
       {
          // Create new snapShots for new recording
          snapShots = new Array(Vector3);
       }
    }
// Toggle playback
    if (Input.GetKeyDown("2"))
    {
       isRecording = false;
       isReplaying = !isReplaying;

       if (isReplaying)
       {
          // Reset currentFrame
          currentFrame = 0;
       }
    }

}

console report:

InvalidCastException: Cannot cast from source type to destination type.
RecorderJS.FixedUpdate ()   (at Assets\scripts\RecorderJS.js:18)

It would help us help you faster if you pointed out which line the error is on.

(When you see an error in the Console, you can double-click it to go right to the problematic line. This works well most of the time.)

This is the line which console refer to:

transform.position = snapShots[currentFrame];

I actually don’t know why this fixes it, but it does.

private var snapShots = new Array ();

And in case you’re wondering, it doesn’t introduce dynamic typing. At least Unity iPhone doesn’t think it does, because it’s not throwing me any errors.

The problem still live, changing into “Array()” didn’t solve the problem

It did on my end.

Did you make sure to change this line, too?

 // Create new snapShots for new recording 
snapShots = new Array(Vector3);