
Chandu J S
Posted on • Edited on • Originally published atchandujs.dev
⛓ How to join two arrays in JavaScript
constone=[`aaa`,`bbb`,`ccc`]consttwo=[`ddd`,`eee`,`fff`]
You have the above arrays.
How will you merge those into a single array?
You can useconcat
method.
This method will work in older browsers also.
constmegaArray=one.concat(two)
There is a new way to do this.
You can use thespread operator in JavaScript.
constmegaArray=[...one,...two]
Much cleaner!
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse