输出结果问题

144 阅读1分钟
  • 1
var b = 1;
function outer() {
    var b = 2
    function inner() {
        b++;
        var b = 3;
        console.log(b)
    }
    inner();
}
outer();
var length = 10;
function fn() {
    console.log(this.length);
}
var obj = {
    length: 5,
    method: function () {
    fn();
    arguments[0]();
  }
}
obj.method(fn, 1);

var b = 10
function fn() {
    console.log(this.b)
}
c = {
    b: 11,
    fn: fn.bind(window)
}
c.fn()
function queue(list){
        // 在这里填写。
}
  
function task1(next){
  setTimeout(function(){
    console.log(1);
    next();
  }, 10000)
}

function task2(next){

  console.log(2)
  next();
}

function task3(next){

  setTimeout(function(){
    console.log(3);
    next();
  }, 200)
}

queue([task1, task2, task3])  // 1 2 3
function queue(list, count){

}
  
function task1(next){
  setTimeout(function(){
    console.log(1);
    next();
  }, 1000)
}

function task2(next){

  console.log(2)
  next();
}

function task3(next){

  setTimeout(function(){
    console.log(3);
    next();
  }, 200)
}
queue([task1, task2, task3], 2)  // 输出 2 3 1
(function(){var aa=bb=3;})(); 
console.log(aa);
console.log(bb);

(function(){var aaa=bbb=3;})(); 
console.log(bbb);
console.log(aaa);

function fun(n){
  console.log(n);
  var n = 456
  console.log(n);
}
var n = 123
fun(n)

function fun(){
  console.log(n);
  var n = 456
  console.log(n);
}
var n = 123
fun(n)

console.log('A')
while(true){
}
console.log('B') 
  • 只输出A
console.log('A')
setTimeout(function(){
  console.log('B') 
},0)
while(true){
}
  • 只输出A