叶家伟
叶家伟
写个js还问GC,有点搞笑了
```js new IntersectionObserver((entries, observer) => { const ratio = entries[0].intersectionRatio; // 元素出现在parent视口中的比例 }, { root: parent, rootMargin: "0px", threshold: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0] }).observe(target)...
```js 首屏时间 输入url到展示页面全部dom为首屏时间 1. 第一个图片加载成功的时间 - head标签顶部记录开始时间 2. const performanceNavigationTiming = performance.getEntries()[0] performanceNavigationTiming.domContentLoadedEventEnd - performanceNavigationTiming.fetchStart 3. 查看 LightHouse 的 First Contentful Paint 白屏时间 输入url到展示第一个dom为白屏时间 1. head标签底部记录结束时间 - head标签顶部记录开始时间 2. performanceNavigationTiming.domInteractive...
```js 网上的这些关于HMR的文章都是为了博眼球吸流量的,放下浮躁的心好好看看源码 webpack.HotModuleReplacementPlugin负责比对module的hash生成 核心代码 hotUpdateMainContentByFilename.set(filename, { removedChunkIds, removedModules, updatedChunkIds, assetInfo }); webpack-hot-middleware负责获取HotModuleReplacementPlugin对比出来的chunk信息丢给客户端 服务端核心代码 function onDone(statsResult) { if (closed) return; // Keep hold of latest stats so they can be propagated...
```js 这道题还是非常不错的,可以锻炼正则和错误处理 function get(obj, path) { const keys = path.split('.'); let res = obj; for(let i = 0; i < keys.length; i++) { const reg = /^(\w+)\[(\d+)\]$/; const key =...
`'reverse' in Reflect.ownKeys(Array.prototype)`
```js arr.filter(item => item > 10).reduce((pre, cur) => pre + cur, 0) ```
```js function shiftArr(arr) { arr = Array.from(arr); const max = Math.max(...arr); arr.sort((a, b) => Math.ceil(Math.random() * max - 1) - b); // 用 ceil - 1 避免两端出现的概率太小 return arr; }...