标准函中的this
标准函数中(相对于箭头函数),this是方法调用的上下文对象。
箭头函数中的this
箭头函数中的this会保留定义该函数时的上下文。
//创建两个对象 分别模拟定义时的上下文和调用时的上下文
let defineContext = {
name : "defineContext"};
let invokeContext = {
name : "invokeContext"}
let standardFunction = null;//用来存一个标准函数
let arrowFunction = null;//用来存一个箭头函数
//在这个函数里定义上述两个函数。在调用这个函数时,通过call将上下文defineContext传入
function defineFunction()