Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Do you leave console.log in your final code?
So I might be getting ahead of myself and this may be covered in later videos, but I'm just curios do you leave console.log in your final code when you publish a site? Or is it just to use while debugging and then should be removed before your code/site is published?
You'll probably want to remove the
console.log calls before going live with a site. They wouldn't hinder the site in any way, but it's the equivalent of cleaning up after work.
If users were to see them on accident, they might be confused by them. Other devs would be surprised you hadn't removed them.
console.log calls less often and they'll be easier to remove.
The only time I leave them in is if I want to make some sort of an easter egg for users. But then the message displayed is intentional and not debug info.
László Győri82,430 Points
You should definitely remove them, because legacy browsers like IE8 and 9 don't support it and it will cause an error, which can affect other pieces of script.
The previous statement is not entirely correct, the console object is supported, but only when the dev tools window is open. This obviously doesn't affect regular users though. Also it can be confusing to hunt errors like this down, because once you open dev tools the error, by design, disappears.
Thanks for the answers guys! Very helpful to know.