I am trying to understand the blocking nature of javascript code. I understand javascript is single threaded. So we have to use timers and callbacks for some features.
In this case, I have a loop that is changing the background color. It doesn't change the bg color until the loop ends. Why? Why can't the browser just update the document color?
<script>
 $(document).ready(function(){
    console.log('hi')
    var x = 0;
    var color = 'red';
    while (x< 10000000) {
        x+= 15 ;
        document.body.style.background = color;
    }
});
</script>
 
     
    