Problem 1: define a function with the same name as an external variable in {}

Var a = 0 if(true){a = 1 function a(){} a = 21 console.log(' internal ', a, window.a)} console.log(' external ', a, window.a)Copy the code

Result output: internal 21 1 External 1 1

This refers to a question

    var length = 10 
    function fn(){
        console.log(this.length)
    }

    var obj = {
        length: 5,
        f : function(fn){
            fn()
            arguments[0]() 
        }
    }
    
    obj.f(fn, 2)
Copy the code

The output is: 10 and 2

Promise. Then execution order

Promise.resolve().then(() = >{
    console.log(0)
    return Promise.resolve(4)
}).then((res) = >{
    console.log(res)
})

Promise.resolve().then(() = >{
    console.log(1)
}).then(() = >{
    console.log(2)
}).then(() = >{
    console.log(3)
}).then(() = >{
    console.log(5)
}).then(() = >{
    console.log(6)
}).then(() = >{
    console.log(7)})Copy the code

0, 1, 2, 3, 4, 5, 6, 7

Analysis:

Object property is an object

let a = { a: 10 }
let b = { b: 10 }
let obj = {
    a : 10
}
obj[b] = 20
console.log(obj[a])
Copy the code

The output is: 20