Does document.write work only when it wants to?
I was trying to understand how document.write and document.writeln is supposed to work in JavaScript, but I cant for the life of me. I made a new project and tried out some things. https://code.sololearn.com/WG7pfOozVics/#js ---------------------------- These are my doubts -> It is supposed to rewrite the document, which means that everything that is written after it shouldn't be executed. That would make sense if it actually always did that (see my example) -> When used simply, it seems to just add to the end of the document, instead of rewriting it -> When used in a loop, it does the same -> But when inside setInterval, It rewrites everything the first time its called -> For some reason, newlines (\n) are replaced by a space. ---------------------------- It would be nice if someone could explain why things are happening the way they are. Thanks.