document.write vs console.log JS | Sololearn: Learn to code for FREE!


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?

3/23/2017 12:20:21 AM


5 Answers

New Answer


"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:


in my opinion console.log is for errors outputs


you can use console.log to check if your script working right


console.log , i usually used for debugging like printf in c while document.write used to display to the document created in html


well, console.log() clearly states that it is logging to the console, whereas document.write() states it is writing to the document.