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 trialRuchika Roy
833 PointsWhat is the difference between document.write() and console.log()?
Don't you usually use console.log() more often? In what situations would using document.write() be preferable to console.log()?
3 Answers
Jake Kobs
9,215 Pointsdocument.write() is generally used in JavaScript to display the information on the webpage. So, if you were to do: document.write("<h1>Hello World!</h1>"); , Hello World! would be displayed on the website page as an h1 element. On the other hand, console.log() is great for programmer use. It can help with listening to events, which you will learn about later in the course.
Ruchika Roy
833 PointsThank you Jake!
Jake Kobs
9,215 PointsYou're welcome! Best wishes on your tech degree journey!
Juan Guerrero
3,994 PointsI wondered this myself. Thanks