Document.write or console.log which is more useful | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Document.write or console.log which is more useful

Java script

30th Mar 2021, 8:53 PM
Ay Top Coder
1 Answer
+ 5
console.log is more useful. console.log is useful for troubleshooting although it is best removed before releasing a production ready version of your code. console.error is also helpful for troubleshooting. I never used document.write in any paid project. HTML is great for defining the initial state of a document. There's no frequent need to write HTML in JavaScript before the HTML loads. After the document loads, there are very good ways to manipulate the document model using JavaScript. There just isn't any cases I can think of for document.write.
30th Mar 2021, 9:18 PM
Josh Greig
Josh Greig - avatar