Typecast in JS?

I know this sounds like a silly question that’s probably been asked before, but, is there a way to typecast in JScript?

Thanks,
Nathan

Mostly it’s done for you. “var foo = Vector3.zero” for example. If you need to, do something like “var foo : Vector3 = Vector3.zero” but most of the time it’s not necessary.

–Eric

Thanks Eric, I appreciate the response.

I meant something more like typecasting such as in this C++ style example:

int myIntA = 1;
int myIntB = 10;

// Converts myIntA to 1.0 and myIntB to 10.0
float myFloat = (float)myIntA / (float)myIntB;

print(myFloat);
// would print "0.1" to the console

Is there something like this in JScript?

Thanks,
Nathan

In that case you’d do

var myFloat = parseFloat(myIntA)/myIntB;

–Eric

Sweet! Thanks Eric, that’s exactly what I was looking for… thanks! :slight_smile: