+ 17

document.write vs console.log JS?

what is best for output? why?thank you kazbahari for comment

16th Mar 2017, 7:05 PM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar
7 ответов
+ 15
console.log is for debugging and testing your code (Development mode only) . document.write for writing to web page (overwrite everything on the web page). I prefer innerHTML: var node = document.getElementById("node_id"); node.innerHTML = "some output";
16th Mar 2017, 8:05 PM
Wisdom Abioye
Wisdom Abioye - avatar
+ 24
Thank you Boris...thank you Baptiste and Wisdom....I am grateful for everyone's encouragement..the encouragement makes me want to study and practice more..today I got a badge for posting a bunch of codes, "code ninja".... my w/l percentage in challenges is not the best so I try other stuff. lots to learn... thank you all. I promise I won't give up. this is a great group of programmers, all of you. very proud to be in this community. cpacebo. dobroe ytrom.
17th Mar 2017, 1:58 AM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar
+ 8
console.log is for debug or error message, document.write is for other output (to write directly in the page)
16th Mar 2017, 7:11 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 7
1000 per day! Well done. How did you do it? Sorry I am out of the topic...but congrats. .
16th Mar 2017, 9:58 PM
Boris Atanasov
Boris Atanasov - avatar
+ 7
Joe, thank you very much!
17th Mar 2017, 6:53 AM
Boris Atanasov
Boris Atanasov - avatar
+ 5
document.write is used to write plain text or HTML content to the page that is visible to the viewers while console.log is used for debugging and it is visible to the developers not normal viewers
19th Mar 2017, 6:32 AM
Hasan Al-Yazidi
Hasan Al-Yazidi - avatar
+ 3
console.log is for debug and the user not will see it in document only in console. document.write will write in document
17th Mar 2017, 10:34 AM
Amstrong Martins
Amstrong Martins - avatar