前端前端
fabric
算法
jsBlock
styleBlock
svgBlock
工具其他
Vue、React相关
webgl
GitHub
fabric
算法
jsBlock
styleBlock
svgBlock
工具其他
Vue、React相关
webgl
GitHub
  • 1_1_nextjs项目开发
  • 1_2_nextjs项目部署
  • React
  • React使用中遇到的一些问题
  • React构建create-react-app简单说明
  • ubuntu使用
  • vue.init
  • vue.use
  • vuex源码解析
  • Vue使用中遇到的一些问题
  • vue梳理
  • watcher&&dep
  • 代码片段
  • 打包
  • 简单双向绑定
  • 纯函数

代码片段

array.length

set中有这么段代码

if (Array.isArray(target) && isValidArrayIndex(key)) {
    target.length = Math.max(target.length, key)
    target.splice(key, 1, val)
    return val
  }

target.length = Math.max(target.length, key) 测试

  const a = [1,2,3]
  a.length = 5 // 不加这一行 [1, 2, 3, 7]
  a.splice(5, 1, 7)
  console.log(a) // [1, 2, 3, empty × 2, 7]

Edit this page
最近更新:: 2021/5/26 17:52
Contributors: wuhui
Prev
watcher&&dep
Next
打包