Is there a difference between document.write() and console.log()? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Is there a difference between document.write() and console.log()?

17th Mar 2018, 4:23 AM
Riley Myers
Riley Myers - avatar
2 Answers
+ 12
The former writes to the HTML page, while the latter writes to the JS console. We would usually use the latter when it comes to debugging purposes.
17th Mar 2018, 4:37 AM
Hatsy Rei
Hatsy Rei - avatar
0
If you want to print something on Web page then you will use document.write()..and If you want to print some in browser console then you will use console.log()..
18th Mar 2018, 7:51 AM
Amit
Amit - avatar