console.log("1");
setTimeout(function () { console.log("2") }, 0)
new Promise(function (resolve) {
console.log('new Promise');
resolve();
}).then(function () {
console.log('then')
});
console.log("3")
输出结果:1 new Promise 3 then 2
console.log(a)
if (a) {
var a = 1;
console.log(a)
}
function a() {
console.log(this);
}
console.log(a);
a()
输出结果:
ƒ a() {
console.log(this);
}
1
1
a is not a function 报错