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

Erwan EL
Erwan EL
7,669 Points

Can anyone explain simply the difference between console.log, console.dir and console.error

Hi i tried all in this course at multiples occasion and i don't really see a difference. Read the documentation too but if anybody can explain it here, could be great.

1 Answer

Jordan Watson
Jordan Watson
14,738 Points

Console.log([1,2,3]) Would usually spit out a string if its not an object thats being logged so in the example it would be "[1,2,3]", console.dir([1,2,3]) would spit out a tree of the array structured so ARRAY: 0: [1], 1:[2], 2: [3]. good place to check for more documentation is Mozilla MDN A lot of documentation on this can be found there.