What is difference between alert command and document.write command in JavaScript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is difference between alert command and document.write command in JavaScript?

17th Sep 2019, 2:52 AM
ansul sharma
ansul sharma - avatar
2 Answers
+ 7
An alert() displays the content in a pop up dialog box while document.write() displays the content in the actual web page.
17th Sep 2019, 1:53 PM
Web Shark
Web Shark - avatar
+ 2
Alert is like a pop up message in your browser window. Document.write writes it onto the document.. which is your browser window. The DOM. Document Object Model. And I know you didn't ask but console.log() is to log the information into the debuggers console that you use.
17th Sep 2019, 3:42 AM
Anthony Johnson
Anthony Johnson - avatar