vue 操作数组的变异方法和非变异方法

变异方法 (mutation method),顾名思义,会改变被这些方法调用的原始数组

  • push( )
  • pop( )
  • shift( )
  • unshift( )
  • splice( ) 
  • sort( )
  • reverse( )

也有非变异 (non-mutating method) 方法,例如:

  • filter( )
  • concat( )
  • slice( )

这些不会改变原始数组,但总是返回一个新数组。当使用非变异方法时,可以用新数组替换旧数组

猜你喜欢

转载自blog.csdn.net/weixin_41796631/article/details/82924362
今日推荐