What is difference between console.log(" "), window.alert(" ") and document.write(" ") in JavaScript?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is difference between console.log(" "), window.alert(" ") and document.write(" ") in JavaScript??

When I write document.write() in ide like vs code or Jetbrains webstorm I got an error and while I write console.log() in html in <script> tag I got an error.

26th Apr 2019, 5:55 PM
Sumit Sinha
Sumit Sinha - avatar
1 Answer
+ 1
console.log adds an log message, alert creates a alert box and document.write allows you to write html into the html document... I can't tell you why you get errors, but here on Sololearn all three functions work perfecly
26th Apr 2019, 8:00 PM
Aaron Eberhardt
Aaron Eberhardt - avatar