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 trialVic Mercier
3,276 Pointsconcat
If I understand this method well, the concat method will add something at the END of an another array?
2 Answers
Steven Parker
231,072 PointsYou 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
3,220 PointsIt 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
231,072 PointsFor 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.
ian izaguirre
3,220 PointsYour right :-)
Trent Stenoien
Full Stack JavaScript Techdegree Graduate 21,632 PointsTrent Stenoien
Full Stack JavaScript Techdegree Graduate 21,632 PointsThe method Vic was describing was Array.prototype.push(), correct?
Steven Parker
231,072 PointsSteven Parker
231,072 PointsMy answer is about
Array.prototype.concat()
, which I believe is the topic of Vic's question.