0

When am I suppose to use console.log , alert() and document.write()

4th Mar 2022, 3:36 PM
Ayoub
Ayoub - avatar
3 Respostas
+ 3
1-console.log-- it is used to write in the console so it will not be visible on the web page but in console--mainly to test a function and for debugging 2-alert()--it will create a popup--it is good to notify a user about something but using alert will block user access to the web page unless the alert popup is gone(clicked somewhere on the page by user) 3-document.write()--write on the web page so anyone accessing the page can see it What-to-use 1-use console.log to test your code(easy for testing) 2-use alert for a prompt(disclaimer!!! it will block user access to the page) 3-document.write to wite on a webpage(mainly by dom to access an Html tag) So.... it entirely depends on your need. Just understand the concept and use it according to your need In simple learning and code testing, console.log is best(my choice)
4th Mar 2022, 5:01 PM
Umar Farooq
+ 4
To print an output Like alert("hi) console.log("hi") document.write("hi")
4th Mar 2022, 3:56 PM
Chigozie Anyaeji 🇳🇬
Chigozie Anyaeji 🇳🇬 - avatar
+ 1
whenever you are not sure what your genial code will output. ))) it calls check or test. And every developer do it.
4th Mar 2022, 3:53 PM
Shadoff
Shadoff - avatar