+ 17
document.write vs console.log JS?
what is best for output? why?thank you kazbahari for comment
7 Respuestas
+ 15
console.log is for debugging and testing your code (Development mode only) .
document.write for writing to web page (overwrite everything on the web page).
I prefer innerHTML:
var node = document.getElementById("node_id");
node.innerHTML = "some output";
+ 24
Thank you Boris...thank you Baptiste and Wisdom....I am grateful for everyone's encouragement..the encouragement makes me want to study and practice more..today I got a badge for posting a bunch of codes, "code ninja".... my w/l percentage in challenges is not the best so I try other stuff. lots to learn...
thank you all. I promise I won't give up. this is a great group of programmers, all of you. very proud to be in this community. cpacebo. dobroe ytrom.
+ 8
console.log is for debug or error message, document.write is for other output (to write directly in the page)
+ 7
1000 per day! Well done. How did you do it? Sorry I am out of the topic...but congrats. .
+ 7
Joe, thank you very much!
+ 5
document.write is used to write plain text or HTML content to the page that is visible to the viewers while console.log is used for debugging and it is visible to the developers not normal viewers
+ 3
console.log is for debug and the user not will see it in document only in console. document.write will write in document