[Javascript] Functions arguments...

Peter-Paul Koch gassinaumasis at hotmail.com
Thu May 3 08:47:24 CDT 2001


>Well, it seems that nobody can help me with the conversion of variant into 
>a
>string...if anyone can, please email the answer, I'm in a hurry...

var x = 4; // x is a number
x = x + 'a'; // now x is a string
OR
x.toString(); now x is a string

var x = '1234'; // x is a string
x = x * 1; // now x is a number

>Meanwhile I want to ask another question...
>How can I pass an argument to a function, modify it inside the function, 
>and
>then that this modification reflects outside the function

var y; // declare global variable y, accessible in all functions

function doIt(x)
{
y = x
}

x is a local variable, you can only read or use it inside the function. 
However, y is global so if you do y = x you load the local value of x as the 
global value of y. y keeps the value until you run the function again.

If you'd done

function doIt(x)
{
var  y = x
}

y would have been a local variable too, usable only inside the function.

>And again, my question...How can I convert a variant type to a string or a 
>byte or an integer???...

These differences do not exist in JavaScript. A variable can be either a 
string or a number, if it's a number you can do anything with it, doesn't 
matter it it's an integer or a float or a double.

ppk
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.





More information about the Javascript mailing list