Page History
...
Multiple functions can exist in the same source file.
function concat ( value1, value2 )
{
return value1 + value2 ;
}
function startDate ( type )
{
if ( type == 'A' )
{
return "30-1-2006" ;
}
return "23-4-2005" ;
}
JavaScript is a loosely typed language.
...
There are several JavaScript functions such as parseFloat, parserInt and the Number object that can be used to convert String values to number values. Also number variables have several built-in functions such as toFixed and toPrecision that allow formatted values to be returned.
value = Number ( value )
value = parseInt ( value )
value = parseFloat ( value )
The following example illustrates these functions.
function changeit ( value )
{
value = Number ( value ) ;
if ( value > 100 )
{
value = value - 100 ;
}
return value.toFixed ( 2 ) ;
}