DEV Community

Clever Cottonmouth
Clever Cottonmouth

Posted on

1

concatenate array using apply

let arr1 = [1,2,3]
let arr2 = [4,5,6]

arr1.push.apply(arr1,arr2)

console.log(arr1)

Top comments (1)

Collapse
 
jonrandy profile image
Jon Randy πŸŽ–οΈ β€’

Why not just:

arr1.push(...arr2)
Enter fullscreen mode Exit fullscreen mode

?

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay