Click to See Complete Forum and Search --> : Loose <type> declarations???


Khalid Ali
07-13-2003, 07:19 AM
I am not sure if anybody out there has the same problem as I do with JavaScripts loose type declarations for variables/objects.

I wish soon they have variable decalrations something like this

var n<Integer or int> = 7;
var dec<float or double> = 3.3;
var flag<boolean or bool or Boolean> = false;
var name<String> = "Bob";

I am pretty sure it will improve performance a great deal because the JS engine will not have to figure the heck out that which <type> the variable is of.

phew...Just wanted to get it out...;)

Charles
07-13-2003, 07:31 AM
I'm not sure that I know what you mean. The interpreter already knows what data type a variable or constant is and how to convert it to the other types. If you put it in quotes then it's a string; there is no character type; true and false are key words that represent boolean values; any number is always a single precision floating point real; there are no integers or doubles. There are also arrays, objects, functions and regular expressions all of which are obvious to the interpreter.