What's the difference between document.write and console.log. I am confused | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's the difference between document.write and console.log. I am confused

Javascript

25th Feb 2021, 8:45 PM
Dayo Akinyemi
Dayo Akinyemi - avatar
4 Answers
+ 1
document.write or access to DOM elements (add nodes, update attributes/content)... but console.log is usefull for debugging ;)
25th Feb 2021, 9:13 PM
visph
visph - avatar
+ 1
-document.write: It's a function to show some output (including text and html elements) on the html page (It's clear everything on the page before doing this). -console.log: It's a function to show some output (only text) on the console's window. Run this example and you will understand the difference better: https://code.sololearn.com/WsUJl31RoADt/?ref=app
25th Feb 2021, 9:18 PM
Mhd AlHaj Houssein
Mhd AlHaj Houssein - avatar
0
document.write output to html document console.log output to browser console (developpers tools)
25th Feb 2021, 8:49 PM
visph
visph - avatar
0
So which is needed in building a website?
25th Feb 2021, 9:10 PM
Dayo Akinyemi
Dayo Akinyemi - avatar