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 Foundations Arrays Methods: Part 1

Emmanuel Koranteng
Emmanuel Koranteng
21,488 Points

.toString();

If "my_array.toString()" returns the string representation of an array, is it necessary to use it when the elements in the array are all strings?

1 Answer

Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hello Emmanuel.

It is only necessary if you want to return a single string with all the strings of the array in 1.

If you need to use them with them property of an array, you should not use it.

Maybe you can have a read here if you like:

http://www.w3schools.com/jsref/jsref_tostring_array.asp

It may help out with the example.

Emmanuel Koranteng
Emmanuel Koranteng
21,488 Points

Is clearer now. Thanks a lot Vitorrio. Very helpful!