[摘要]下面给出一个完成的函数,仔细的体会一下。function getConditions(strCity : String) : String var now : Date = new Date(); switch (strCity.toUpperCase()) case "...
下面给出一个完成的函数,仔细的体会一下。
function getConditions(strCity : String) : String
{
var now : Date = new Date();
switch (strCity.toUpperCase())
{
case "LONDON":
if (now.getMonth() <= 7 now.getMonth() >= 9)
{
return "overcast";
}
else
{
return "partly overcast and humid";
}
break;
case "SEATTLE":
if (now.getMonth() == 7 && now.getDay() == 4)
{
return "torrential rain";
}
else
{
return "rain";
}
break;
case "LA":
return "smoggy";
break;
case "PHOENIX":
return "damn hot";
break;
default:
return "partly cloudy with a chance of showers";
}
}
使用Jscript.net,你也可以定义其他.net架构的类型,通过引用命名空间和派生类可以向Jscript.net引入新的数据类型。这样在两者的数据类型中就有可能产生重叠。参见下表:
Boolean .NET Framework Boolean / JScript boolean
Number .NET Framework Double / JScript number
String .NET Framework String / JScript string
Int .NET Framework Int32
Long .NET Framework Int64
Float .NET Framework Single
Double .NET Framework Double
Object .NET Framework Object / JScript Object
Date JScript Date object
Array JScript Array
Function JScript Function object
……