JS-34 数组方法_concat()

concat方法用于多个数组的合并。它将新数组的成员,添加到原数组成员的后部,然后返回一个新数组,原数组不变

['hello'].concat(['world'])

//["hello","world"]

['hello'].concat(['world'],['!'])

//["hello",'world','!']

除了数组作为参数,consat叶接受其他类型的值作为参数,天骄到目标数组尾部。

[1,2,3].concat(4,5,6)

//[1,2,3,4,5,6]

应用场景:上拉加载,合并数据

 

posted @ 2025-01-14 20:55  张筱菓  阅读(29)  评论(0)    收藏  举报