Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我已经看到了这一点,但不确定这意味着什么_Javascript - Fatal编程技术网

Javascript 我已经看到了这一点,但不确定这意味着什么

Javascript 我已经看到了这一点,但不确定这意味着什么,javascript,Javascript,我一直在研究一些javascript代码,并注意到这一点,我不知道它是做什么的,为什么要使用它 let reset = function(a, b){ b || (b = something, b.somethingelse && (b.other = b.somethingelse)) //.... //some other code underneath } 如果您能帮助我理解这一点,那就太好了这是以下的缩小版: let reset = function(a

我一直在研究一些javascript代码,并注意到这一点,我不知道它是做什么的,为什么要使用它

let reset = function(a, b){
    b || (b = something, b.somethingelse && (b.other = b.somethingelse)) //....
    //some other code underneath
}

如果您能帮助我理解这一点,那就太好了

这是以下的缩小版:

let reset = function(a, b) {
  if (!b) {
    b = something;
    if (b.somethingelse) {
      b.other = b.somethingelse;
    }
  }
  //some other code underneath
}

缩小版(取决于与
|
&
的组合,如果
如果
如果
测试,则就地
&
测试)完全不可读,但当脚本通过internet发送给用户时,它会节省一些字节。当试图找出并调试代码时,最好阅读源代码,而不是缩小版本。

以上是此代码的缩小版本:

let reset = function(a, b) {
  if (!b) {
    b = something;
    if (b.somethingelse) {
      b.other = b.somethingelse;
    }
  }
  //some other code underneath
}

检查一下哪一个在使用变量名的情况下也能很好地清除代码呢?

干杯我需要它,它工作得很好其他清除代码的人喜欢或不喜欢它,因为他们只会让它看起来很好,如果语句和循环etcI以前见过它们,并且它们工作得不好,就不会带回来,下次我会记住这一点,很高兴我能帮上忙