Javascript的变量范围是以函数为基础的。每个函数都有它自己的变量范围,而不是花括弧包起来的范围。 var herp=”one”; { var herp=”two”; } alert(herp); 你会发现 弹出的是two而不是one.