+ 2
When should document.write and console.log be used?
8 Réponses
+ 2
The console.log() method writes a message to the console.The console is useful for testing purposes.
While the write() method writes HTML expressions or JavaScript code to a document. The write() method is mostly used for testing: If it is used after an HTML document is fully loaded, it will delete all existing HTML.
+ 6
Priyanshu Sharma hello,if you want to know in detail then you can visit this sites
Document.write method
https://www.w3schools.com/jsref/met_doc_write.asp
Console.log method
https://www.w3schools.com/jsref/met_console_log.asp
+ 6
Priyanshu Sharma Good answer!
but try to use try google for this common types of questions...
Many websites and Youtube Tutorial available you can know in detail from there.
+ 5
document.write("this is write");
console.log("this is log");
Copy paste in javascript section of html code and see the effect
+ 2
ᕙ(@°▽°@)ᕗ
Ok
Thank you...
I got it.
+ 2
document.write() gives new learner a feel of how JS affects the DOM of the page. As a developer however I advise to use the methods of console. Not only log() exists but many others and each has it's own helpful function
+ 1
Царь СОБАКА - Догго I
So if we use document.write then the existing html output will be over written by the document.write...
Is that what you say
+ 1
And if we use console.log then where we get the output
as it will be displayed in the console...
I didn't get it please explain...