记录一些js常用技巧

245 阅读1分钟
  1. 移除所有的 ”false“ 类型元素

[1,2,"b",0,{},"",NaN,3,undefined,null,5].filter(Boolean)
=>[1, 2, "b", {}, 3, 5]

   2.生成随机码 来源redux源码

const randomString = () => Math.random()
                           .toString(36)
                           .substring(7)
                           .split('')
                           .join('.')