When I do:
<!DOCTYPE html>
<html><head><title></title></head>
<body>
<div id="root"></div>
<script>
let a = document.getElementById('root');
console.log(a);
a.append('cat');
console.log(a);
</script>
</body></html>
I expect the console to be:
<div id="root"></div>
<div id="root">cat</div>
But I get:
<div id="root">cat</div>
<div id="root">cat</div>
Its like the .append('cat') command runs before the first console.log() command. How is this? I thought programming code was always executed sequentially. Where can I learn which code executes sequentially and which ones don't in Javascript?
This might be a problem if I'm trying to debug more complex code later.