Day9

1-说说你对 this 的理解

  this 是全局对象,可以作为方法调用

2-call\apply\bind 的区别和联系?

  call apply bind 都能改变函数的内部this指向

  call 和apply在改变函数this指向的同时会调用函数,但是传递参数的形式不同,call是一个一个的接收参数,而apply是以数组的形式接收参数,call通常是和构造函数来模拟继承。

3-下面代码执行的结果是什么?

var hellword=(function(){
console.log("hello one");
setTimeout(() => {
console.log("hello two")
},100);
setTimeout(() => {
console.log("hello three")
}, 0);
console.log("hello four")
}())

结果:

  hello one

  hello four

  hello three

  hello two

4-下面代码执行的结果是什么

  var a={
    id:0
  }
    b=a;
    b.id=1;
    b.name="test";
  console.log(a)

 

结果:

  1. id: 1
  2. name: "test"
posted @ 2021-02-06 19:05  warisFairy  阅读(31)  评论(0)    收藏  举报