XinChou16 / MIX

https://xinchou16.github.io/MIX/index.html
1 stars 0 forks source link

风格指南参考 #16

Open XinChou16 opened 5 years ago

XinChou16 commented 5 years ago

风格指南 https://github.com/lin-123/javascript#functions

隐藏类型转换

https://github.com/lin-123/javascript#comparison-operators--equality

15.7 避免不需要的三元表达式

XinChou16 commented 5 years ago

开发调试 https://juejin.im/entry/5b7cb52fe51d4538c86cfd75

XinChou16 commented 5 years ago
result.sort(function (a, b) {
    if (a[0] < b[0]) {
      return -1
    }
    if (a[0] > b[0]) {
      return 1
    }
    if (a[0] === b[0]) {
      if (b[1].indexOf('.webp', b[1].length - 5) !== -1) {
        return 1
      }
      if (a[1].indexOf('.webp', a[1].length - 5) !== -1) {
        return -1
      }
    }
    return 0
  })

https://github.com/hilongjw/vue-lazyload/blob/master/src/util.js