Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Useful Array Methods

Vic Mercier
Vic Mercier
3,276 Points

concat

If I understand this method well, the concat method will add something at the END of an another array?

2 Answers

Steven Parker
Steven Parker
231,269 Points

You have the basic idea.

But it does not modify the array directly. Instead, it returns a new array composed of the others joined together.

Check the MDN page for more information.

ian izaguirre
ian izaguirre
3,220 Points

It would be incorrect to say that concat will add "something" at the end of an Array. I think thats why Trent that commented above was confused, since you used the word "something".

The difference between Push and Concat would be that concat deals with arrays. Concat merges two or more arrays while also not changing the original array and rather just returns a new array as the result.

... If we had an example that had an array with only one value and you wanted to add it to another array, then what would be another difference between using Concat vs Push? That would be that Push would change the original array and return the length of the array.

Steven Parker
Steven Parker
231,269 Points

For some students, English is as much of a challenge as the technology. I try to give some leeway on the language and do my best to "interpret" the underlying quesiton.