I have some questions about a javascript behaviour (I am learning now javascript from w3schools) and I've seen two examples with a simple code,but I don't understand why the code is behaving different: First example:
<!DOCTYPE html>
<html>
<body>
<h1>My First Web Page</h1>
<p>My first paragraph.</p>
<script>
document.write(5 + 6);
</script>
</body>
</html>
Second example:
<!DOCTYPE html>
<html>
<body>
<h1>My First Web Page</h1>
<p>My first paragraph.</p>
<button onclick="document.write(5 + 6)">Try it</button>
</body>
</html>
Why in the second example all document content is replaced with "11" and in the first example "11" as appended to the document? Is there a difference when the script is executed?
Ps: I know that this is not the right place to ask this, but if you know a better book or tutorial to learn javascript, please put it in a comment ( I am a c# backend developer and ex android developer).
document.writeever.