+ 2
Javascript question
What is the difference between document.write and console.log
3 Answers
+ 5
console.log("") - outputs whatever is parameter to log() to a console
e.g. console.log("test") will output "test" to ur console
document.write("") adds whatever u want to html
e.g. document.write("<p>paragraph</p>") will add a new paragraph to a document
For more:
1-https://www.codecademy.com/en/forum_questions/53121d097c82ca0a33003906
2-https://www.sololearn.com/Discuss/25652/what-is-difference-between-document-write-and-console-log
+ 3
Basically (window.)document.write() writes a string to the screen. Hereby it rewrites the document, so the browser has to interpret it again. (window.)console.log() however only writes a string to the console of a browser, so it doesn't have to be reinterpreted by the browser. For more information see this link:
https://www.codecademy.com/en/forum_questions/53121d097c82ca0a33003906
+ 1
Document.write writes HTML to the page of your document.
Console.log prints whatever you are logging to the console.
For example:
console.log("Hello World");