using public JS variables in C#

hey i dont know how to access public variables written in JS.

lets say i have a JS script that is this :

var varToAccess : float = 1.0;

function Start () {}

function Update () {}

i want to be able to access the varToAccess variable in C#. i thought this would work but it doesnt.

public float JSVar;

void Start () {
	JSVar = GetComponent().varToAccess;
	Debug.Log(JSVar);
}

void Update () {}

how do u access public vars written in another language?

Make sure your JS file is in a folder called Plugins or Standard Assets and then do the following:

using UnityEngine;
using System.Collections;

public class TestCS : MonoBehaviour
{
	void Awake()
	{
		TestJS jsFile = GetComponent(typeof(TestJS)) as TestJS;
		Debug.Log(jsFile.test);
	}
}

where your JS file looks like so:

#pragma strict

var test = 5;