+ 18
document.write vs console.log JS
when is it best to use document.write for output? why is it sometimes "best practice" to use console.log for output?
5 Answers
+ 17
"document.write is used on an HTML page to display text on the screen.
...
console.log was created to make our life easier when we test our code. It logs to the screen the result we are looking for."
Source: https://www.codecademy.com/en/forum_questions/53121d097c82ca0a33003906
+ 5
in my opinion console.log is for errors outputs
+ 3
you can use console.log to check if your script working right
+ 2
console.log , i usually used for debugging like printf in c while document.write used to display to the document created in html
+ 1
well, console.log() clearly states that it is logging to the console, whereas document.write() states it is writing to the document.