-1
var x = 'hello';
var x = 'world';

function foo(){
    var y = x = 'hello from foo';
}
foo();

是 x = '来自 foo 的你好',y = '来自 foo 的你好'?

4

1 回答 1

2

使用您的代码,xis 'hello from foo'yis undefined

foo中,你先赋值'hello from foo'给全局变量x,然后再赋值x给局部变量y

于 2012-08-17T06:02:35.800 回答