函数中的this指向
    谁调用这个函数 this就指向谁,没有就是window
    匿名函数在非严格模式下被window调用
    关于原型见 原型 原型链

    image.png
    https://juejin.im/post/59bfe84351882531b730bac2#heading-9

    apply/call/bind
    劫持另一个对象并继承他的属性,可以改变this指向
    apply的第一个参数是改变this指向的对象, 第二个是形参数组
    call的第一个之后的参数是每一个形参
    bind会新建一个函数,必须手动调用。用法是a.bind(b, 1, 2)()
    apply妙用
    Math.max.apply(null,arr) 不循环数组求最大/小值
    Array.prototype.push.apply(arr1,arr2) 合并两个数组(类似concat但会改变第一个数组的值)
    https://www.jianshu.com/p/4d17f1b147fc
    https://www.cnblogs.com/xiaohongwu/archive/2011/06/15/2081237.html

    手写call apply bind

    1. Function.pototype._call = function () { // _call 需要写在function的原型上
    2. const ctx = arguments[0] || window; // 传入的第一个参数决定this指向谁,没有参数则指向window
    3. let fn = Symbol(); // es6用法 避免函数fn重名
    4. ctx.fn = this; // 将执行的函数赋值给改变指向的对象(ctx)的属性(fn)
    5. // let args = [].shift.call(arguments); // 取其它参数
    6. let args = []; // 取其它参数
    7. for (let i = 1; i < arguments.length; i++) { // apply的话第二个参数是数组,取arguments[1]
    8. args.push(arguments[i]);
    9. }
    10. // 执行已经改变this指向的对象上的方法并传参
    11. let res = ctx.fn(...args);
    12. // _bind返回一个函数
    13. // let res = function () {
    14. // ctx.fn(...args);
    15. //}
    16. // 删除这个方法
    17. delete ctx.fn;
    18. // 将结果返回
    19. return res;
    20. }

    https://www.jianshu.com/p/08238efc6a9b
    https://www.jianshu.com/p/4bf613cb393e
    https://www.cnblogs.com/620chang/p/12699102.html