面试题

var num = 12;
window.setTimeout(function(){
    num += 100;
    console.log(num);    
},1000);
console.log(num);

var num = 12;
window.setTimeout(function(){
    num = 100;
    console.log(num);    
},1000);
while(1){
    console.log(num);
}

var total = 0;
function sum(n){
  if(n == 0){
    return;
  }
  total += n;
  sum(--n);
}
sum(10);
console.log(total);
// 12、112 // 12死循环
// 获取1到10的和

 

posted @ 2015-08-20 17:30  ntscshen  阅读(95)  评论(0编辑  收藏  举报