日期:2014-05-16 浏览次数:20451 次
var scope = "global";
function f()
{
alert(scope); // [color=green]显示“undefined”而不是“global”[/color]
var scope = "local"; // 变量做此处定义,但是到处都有定义
alert(scope); // 显示“local”
}
//等价于下面:
var scope = "global";
function f()
{
var scope;
alert(scope);
scope = "local";
alert(scope); // 显示“local”
}
1 + 2 结果: 3
"1" + 2 结果: "12"
"1" + "2" 结果: "12"
11 < 3 结果: false
"11" < "3" 结果: true
"11" < 3 结果: false
"one" < 3 结果: false
1 + 2 + "hello" 结果: 3hello
"hello" + 1 + 2 结果 hello12
(1) function f(x,y)
{
return ;
}
(2) var f = new Function("x","y","return ;");
(3) var f = function(x,y)
{
return;
}
function square(x) {return x * x;}
var b = square;
var c = b(5); //等价于 var c = square(5);
function f(x,y,z)
{
// 判断传递机进来的参数是否是三个
if(arguments.length == 3)
{
}
}
function(x)
{
if(x <= 1)
{
return 1;
}
return x * arguments.callee(x - 1);
}