js 异步
https://www.w3schools.com/js/js_async.asp
search
search()的参数是正则表达式,而indexOf()的参数只是普通的字符串。indexOf()是比search()更加底层的方法。
如果只是兑一个具体字符串来茶渣检索,那么使用indexOf()的系统资源消耗更小,效率更高;如果查找具有某些特征的字符串(例如查找以a开头,后面是数字的字符串),那么indexOf()就无能为力,必须要使用正则表达式和search()方法了。
大多是时候用indexOf()不是为了真的想知道子字符串的位置,而是想知道长字符串中有没有包含这个子字符串。若果返回索引为-1,那么说明没有,反之则有。
startsWith
startsWith endsWith includes
search find findIndex
includes
似乎比 indexOf 厉害一点
| 1 | var arr = ['a','b', 'c', NaN]; | 
| 1 | var arr = new Array(3); | 
fill 的小问题
| 1 | a = Array(10).fill({'hello':'goodbye'}); | 
| 1 | aa = Array(10).fill().map(k=>({hello:'world'})); | 
// 只有第一个会变 // 以下皆是
| 1 | aaa = Array.from({length:10},()=> ({'hello':'goodbye'})) | 
| 1 | aaaa = [...new Array(10)].map(()=> ({'hello':'goodbye'})); | 
repeat
https://www.samanthaming.com/tidbits/22-2-ways-to-repeat-strings/