Chen Yinyi
Chen Yinyi
> ### 哈希表,时间复杂度O(n) > ```js > const fn = arr => { > const res = [] > const map = arr.reduce((res, item) => ((res[item.id] = item), res), {}) >...
[JS实现版本](https://codepen.io/CYSILVER/pen/xxKRKbP?editors=1111) - 使用split + 正则表达式将单词与单个文字切割出来存入words - 加上 '...' - 判断scrollHeight与clientHeight,超出的话就从words中pop一个出来 ```html 这是一段测试文字,this is some test text,测试文字,测试文字测 ``` ```javascript const p = document.querySelector('p') let words = p.innerHTML.split(/(?
In some browsers eg: old safari webview, Object.getOwnPropertyNames will return key 'caller', this will cause code throw error ```js new Set(Object.getOwnPropertyNames(Symbol).map(key => Symbol[key]).filter(item => typeof item === 'symbol')) ``` in...