前端杂谈

1.JavaScript中的this:http://www.ruanyifeng.com/blog/2018/06/javascript-this.html

 

2.js中字符串匹配,"index.html".indexOf(".html") != -1

因为search和match的参数都是正则表达式,在匹配特殊字符时需要转化

 

3.windows10环境下如何干净地卸载node、npm

  1)进控制面板--程序--卸载 node.js

  2)删除安装路径下的文件

  3)删除C:\Users\liwen\AppData\Roaming\npm

               C:\Users\liwen\AppData\Roaming\npm-cache

4.数组克隆

不能只是复制数组的地址,而是一个新的数组,利用扩展运算符。扩展运算符(spread)是三个点(...),将一个数组转为用逗号分隔的参数序列。(但我觉得es5的写法速度更快,虽然我没有测过,我猜的)。

// es5
const
a1 = [1, 2]; const a2 = a1.concat();
// es6
const
a1 = [1, 2]; const a2 = [...a1];

 

posted @ 2018-07-08 18:00  swallowblank  阅读(100)  评论(0编辑  收藏  举报