Typecasting in Javascript?

I can’t seem to figure out how to typecast in Unity’s Javascript. I’ve tried:

float(num) 
Float(num) <-- the normal way to typecast in JS, according to Google. 
(float)num 
num.toFloat() and various other toFloat syntaxes

The only method i’ve found that works is creating a temporary variable:

var sx : float = screen.width;

Obviously this makes for much uglier-than-necessary code. How do you typecast in JS?

That’s the only one available at the moment…

Well apart from this:

  (0.0 + screen.width)

Dang! … placing that edit button next to the quote button is DANGEROUS!

I’m getting a typecasting problem, but the above solution doesn’t seem to work. I’m doing:

var charColliders : Collider[] = GetComponentsInChildren(Collider);

Thanks in advance.

GetComponentsInChildren returns Component[ ]. While Javasccript knows how to cast Component into Collider, apparently it can’t do the same for arrays of them. So what you do is:

var charColliders : Component[] = GetComponentsInChildren(Collider);
for (c=0;c<charcolliders.length;c++) {
var thisCollider : Collider = charColliders[c];
//whatever you're doing to those colliders
}

any idea how to properly typecast this (Editor Script):

var esinstance : ExampleScript = (ExampleScript)target;

Cheers

AC