前端面试题

1、请描述控制台输出的数字顺序

console.log(1);
this.$http.get("api/data1").then((x) => {
  console.log(2);
  this.$http.post("api/data2", x).then(() => {
    console.log(3);
  });
  console.log(4);
});
console.log(5);

答:__ __ __ __ __


2、请描述控制台输出

const source = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const arr1 = source.filter((item) => item % 3 === 2);
const arr2 = arr1.map((item) => item - 2);
console.log(arr2);

答:


3、请描述控制台输出

  fun(n: number) {
    if (n <= 1) {
      return 1;
    }
    const num = n * this.fun(n - 1);
    console.log(num);
    return num;
  }

  fun(4);

答:


4、请描述控制台输出

console.log(1);
this.$http.get("api/data1").then(() => {
  console.log(2);
});

const res = await this.$http.get("api/data1").then(() => {
  console.log(3);
  return 4;
});
console.log(res);

答:

你可能感兴趣的:(前端面试题)