前端筆試小題

/*一.變量作用域一道小題*/
var x='a';
function printX(){
 console.log(x);
 var x='b';
 console.log(x);
}
printX();

var y='c';
function printY(){
 console.log(y);
 y='d';
 console.log(y);
}
printY();
//輸出結果undefined,b,c,d

/*二.輸出結果*/
//alert(null instanceof Object);
//alert(null == undefined);//true
//alert(NaN == NaN);
//alert(false == undefined);

/*三.考察局部變量*/
function foo(a){
 var a;
 return a;
}
function bar(a){
 var a="bye";
 return a;
}
alert([foo('hello'),bar('hello')]);//hello,bye

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章