0
What is the difference between document.write() and console.log()?
Hi im trying my best to leanr programming.
3 Answers
+ 1
Ok thanks soo much!
0
document.write() will show the output in webpage as a part of the page.. And if you use document.write() function it will first clear the index page or homepage... totally clear... and the show the output
Example:
<body>
hello </body>
output: hello
window.onload = function () { document.write ("bye"); }
output: bye
Note: Hello removed
And console.log() will show the output in a terminal..
I learned that coders use it to see, if everything is going fine..
I mean console.log (;
This will show an error in the terminal because ')' missing..
And try to use more meaningful tags.. like JavaScript, sololearn, function etc..
I learned JavaScript a long time ago.. Now, I am learning programming..
So I may be wrong.. please correct me dear viewersđ