+ 5

Silly but is console.log() and document.write() the same action?

So are they the same things? What is the difference.

30th Jan 2022, 8:25 PM
Chelsie Herr
Chelsie Herr - avatar
5 Respuestas
+ 3
Console.log is some text that gets logged in the console/terminal of your ide if you use one. Document.write gets displayed on the site.
31st Jan 2022, 2:54 AM
Adwait Misra
Adwait Misra - avatar
+ 6
console.log ls prints a text in console, document.write Is prints text in website so they have difference
30th Jan 2022, 8:31 PM
Beary
Beary - avatar
+ 6
console.log() will log your data in console, and here you will be able to debug it like you can see a object and it's property, but document.write simply add that text in html section
1st Feb 2022, 8:32 AM
Nandini Garg
Nandini Garg - avatar
+ 3
document.write("something") will print content inside as new document to webpage, also if you have any html code and you run this it will change document and overide to new value you entered, so because of that, document.write is not used too much. You can use this to render your page using js. console.log("something") allow you to log anything you need to console, it is very good for debuging and tracking how your value change in your code
30th Jan 2022, 8:47 PM
PanicS
PanicS - avatar
+ 2
console.log( ) also add a new line. If you wanna print in the same line, you may try process.stdout.write( )
30th Jan 2022, 8:55 PM
Mario Paes
Mario Paes - avatar