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

Varuzhan Darbinyan
Varuzhan Darbinyan
8,360 Points

.push() Method

Why in console.log I get different output for both? In lesson "Methods: Part 1" Jim said that they should be the same after script execution if you do not use .toString()

var fruits = ["Banana", "Orange", "Apple", "Mango"];


in console i get

["Banana", "Orange", "Apple", "Mango"]
["Banana", "Orange", "Apple", "Mango", "Kiwi"]

but according to lesson it should be like this, if I don't use .toString()

["Banana", "Orange", "Apple", "Mango"]
["Banana", "Orange", "Apple", "Mango"]

2 Answers

I get the same thing as you do in my console. Jim was referring to a quirk in the browser's console behaviour that used to occur in an older version of Chrome he was using when he recorded these videos. So you should not be worried about this small difference.

Note that this is not the only situation where the browser behaviour changed from what is presented in these videos. For example, in one of the previous sessions he mentioned that the value of undefined can be set to something else. That is no longer the case with the later versions of the Chrome browser. Setting a value for undefined does nothing.

Brent Suggs
.a{fill-rule:evenodd;}techdegree seal-36
Brent Suggs
Front End Web Development Techdegree Graduate 21,343 Points

Are you running this code directly from the console? If so then the .toString() won't matter, but if executing the script by loading it into a html page it will make a difference is what Jim is saying.