首页 > 解决方案 > 为什么 JavaScript 缩小器不使用它分配给“this”的变量

问题描述

当我缩小我的代码时,我注意到缩小器会做一些类似的事情(为了可读性而格式化):

e.prototype.doSomething = function(){
  var s=this;
  this.anotherThing();
  ........ //more code
}

为什么它不使用s.anotherThing()并继续使用this. 似乎它仅在从我的 doSomething() 函数中的函数或回调的内部范围s引用时使用。this

标签: javascriptminify

解决方案


推荐阅读