ES6
Yoga99
这个作者很懒,什么都没留下…
展开
-
记录 js 多条if判断分支优化
记录 js 多条判断分支优化原创 2023-02-17 09:28:32 · 701 阅读 · 0 评论 -
34种JavaScript简写优化技术
作者:Ting Yu 链接:https://zhuanlan.zhihu.com/p/405787550 来源:知乎 1.如果有多个条件 我们可以在数组中存储多个值,并且可以使用数组 include 方法。 //Longhand if (x === 'abc' || x === 'def' || x === 'ghi' || x ==='jkl') { //logic } //Shorthand if (['abc', 'def', 'ghi', 'jkl'].includes(x)) { //l转载 2021-11-12 13:51:58 · 92 阅读 · 0 评论 -
前端 ES6 使用技巧
// if条件判断 if( type == 1 || type == 2 || type == 3 || type == 4 || ){ //... } //改进 ES6中数组实例方法includes const condition = [1,2,3,4]; if( condition.includes(type) ){ //... } // 前端搜索 过滤 const a = [1,2,3,4,5]; const result = a.filter(原创 2021-10-26 09:33:34 · 170 阅读 · 0 评论