I thought in JavaScript we used "console.log" to display codes | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I thought in JavaScript we used "console.log" to display codes

29th Apr 2020, 11:49 AM
TONICswift
TONICswift - avatar
3 Answers
+ 1
document.write() is a way to do, but even better practice would be to use the dom api to update its content rather than "streaming" raw content to the document (wich once "closed" will be implicitly opened to a completly new document on the first document.write() occuring). Anyway, it's an quick and easy way to do basics output quite as with console.log(), but in more convenient way and sooooo much less intrusive than alert() ;)
29th Apr 2020, 11:59 AM
visph
visph - avatar
0
Ohh. Tnx
29th Apr 2020, 11:53 AM
TONICswift
TONICswift - avatar
0
As swim says, but if you use document.write to show the data insert from user, you must pay attention to XSS vulberabilty.
29th Apr 2020, 11:57 AM
LoCoding
LoCoding - avatar