+ 1
document.write() VS console.log()
While browsing through some other Javascript material, I saw console.log() used instead of the regular document.write() used here in Sololearn. Please in case are they applicable or can they be used interchangeably?
2 ответов
+ 4
document.write() is for modifying HTML content, and console.log() is for outputtibg to the console.
+ 2
Okay. I get it now. In that case, I think it's preferable to output to the console instead since it won't affect the markup. Document.write() might unintentionally wipe up existing HTML content.