奇怪的面试题

变量的面试题

var a = 1;
console.log(a);
if (true) {
  a = 2;
  function a () { }
  a = 3
  console.log(a);
}
console.log(a);
// 1 3 2

promise的面试题

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);
})

// 0 1 2 3 4 5 6
posted @ 2023-02-12 15:30  iooz  阅读(20)  评论(0)    收藏  举报