myUnderscore
  • myUnderscore
  • 基础篇-将函数挂载到'_'上
    • 函数式风格调用
    • 实现面向对象风格调用。
    • 链式调用
  • 类数组与最大安全数
  • 函数判断与Js中的’&& ||‘+假值
  • 字符串反转
  • 高阶函数篇
    • every和some
    • sortBy和闭包
    • 用于调试的tap()
    • unary和parseInt的经典大坑
    • once 和 它牵扯出的this
    • this
      • 调用位置和绑定规则
      • 隐式绑定与隐式丢失
      • 显式绑定与硬绑定
      • new绑定和优先级
      • 被忽略的this和更安全的this用法
      • 软绑定和箭头函数的this
      • 遗留问题:硬绑定无法被改绑的原理是什么?
  • memoized 函数
  • forEach,map 和 reduce
  • filter 过滤器 和 zip 合并数组
  • flatten数组扁平化
  • 避免XXS攻击的字符转义(escape)和反转义(unescape)
Powered by GitBook
On this page

Was this helpful?

  1. 高阶函数篇
  2. this

遗留问题:硬绑定无法被改绑的原理是什么?

var obj1 = {
    a:1

};
var obj2 = {
    a:2
};

function foo(){
    console.log(this.a);
}

var bar = foo.bind(obj1);
bar();//1
bar.call(obj2);//1 硬绑定无法被改绑
Previous软绑定和箭头函数的thisNextmemoized 函数

Last updated 5 years ago

Was this helpful?