js声明变量作用域会提前

 

var s = 1;

function test() {

console.info(s);

var s = 2;

console.info(s);

} 

test();

 

>>>undefined

>>>2

 

posted @ 2018-03-14 17:43  Alice_Xu  阅读(141)  评论(0编辑  收藏  举报